Java Code Examples for org.eclipse.jface.dialogs.IDialogConstants

The following are top voted examples for showing how to use org.eclipse.jface.dialogs.IDialogConstants. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: ide-plugins   File: CodeSWT.java   Source Code and License 6 votes vote down vote up
@Override
protected void createButtonsForButtonBar(Composite parent) {
    super.createButtonsForButtonBar(parent);

    Button ok = getButton(IDialogConstants.OK_ID);
    ok.setText("Apply");
    ok.setEnabled(false);
    setButtonLayoutData(ok);
    
    Button cancel = getButton(IDialogConstants.CANCEL_ID);
    cancel.setText("Cancel");
    setButtonLayoutData(cancel);
    cancel.addListener(SWT.Selection, e -> {
        if (futureTask != null && ! futureTask.isDone()) {
            futureTask.cancel(true);
        }
        code.setFunctionName(null);
        code.setFunctionGivenName(null);
        code.setResultType(null);
        code.setReturnedType(null);
    });
}
 
Example 2
Project: ide-plugins   File: PluginsSWT.java   Source Code and License 6 votes vote down vote up
private void redrawTables() {
    Table sourceTable = sourceTableViewer.getTable();
    sourceTable.setRedraw(false);
    clean(sourceTable);
    source.sort(Plugin::compareTo);
    sourceTableViewer.setInput(source);
    btnSelectAll.setEnabled(source.size() > 0);
    sourceTable.setRedraw(true);
    checkSelection(sourceTable);

    Table targetTable = targetTableViewer.getTable();
    targetTable.setRedraw(false);
    clean(targetTable);
    target.sort(Plugin::compareTo);
    targetTableViewer.setInput(target);
    btnDeselectAll.setEnabled(target.size() > 0);
    targetTable.setRedraw(true);
    checkSelection(targetTable);

    if (getButton(IDialogConstants.OK_ID) != null) {
        getButton(IDialogConstants.OK_ID).setEnabled(! targetOriginal.equals(target));
    }
}
 
Example 3
Project: ide-plugins   File: PluginDialog.java   Source Code and License 6 votes vote down vote up
@Override
protected Control createButtonBar(Composite parent) {
    final Composite buttonBar = new Composite(parent, SWT.NONE);
    buttonBar.setBackground(backColor);
    		
    final GridLayout layout = new GridLayout();
    layout.marginLeft = 10;
    layout.numColumns = 2;
    layout.makeColumnsEqualWidth = false;
    layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
    buttonBar.setLayout(layout);

    final GridData data = new GridData(SWT.FILL, SWT.CENTER, true, false);
    data.grabExcessHorizontalSpace = true;
    data.grabExcessVerticalSpace = false;
    buttonBar.setLayoutData(data);

    buttonBar.setFont(parent.getFont());

    // add the dialog's button bar to the right
    buttonControl = super.createButtonBar(buttonBar);
    buttonControl.setBackground(backColor);
    buttonControl.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, true, false));

    return buttonBar;
}
 
Example 4
Project: ide-plugins   File: ApplicationsSWT.java   Source Code and License 6 votes vote down vote up
@Override
protected void createButtonsForButtonBar(Composite parent) {
    super.createButtonsForButtonBar(parent);

    Button ok = getButton(IDialogConstants.OK_ID);
    ok.setText("Apply");
    ok.setEnabled(false);
    setButtonLayoutData(ok);
    
    Button cancel = getButton(IDialogConstants.CANCEL_ID);
    cancel.setText("Cancel");
    setButtonLayoutData(cancel);
    cancel.addListener(SWT.Selection, e -> {
        if (futureTask != null && ! futureTask.isDone()) {
            futureTask.cancel(true);
        }
        credentials.setApplication(null); 
    });
}
 
Example 5
Project: neoscada   File: HiveTab.java   Source Code and License 6 votes vote down vote up
protected void chooseWorkspace ()
{
    final ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog ( getShell (), new WorkbenchLabelProvider (), new WorkbenchContentProvider () );
    dialog.setTitle ( "Select driver exporter configuration file" );
    dialog.setMessage ( "Choose a driver exporter file for the configuration" );
    dialog.setInput ( ResourcesPlugin.getWorkspace ().getRoot () );
    dialog.setComparator ( new ResourceComparator ( ResourceComparator.NAME ) );
    dialog.setAllowMultiple ( true );
    dialog.setDialogBoundsSettings ( getDialogBoundsSettings ( HiveTab.WORKSPACE_SELECTION_DIALOG ), Dialog.DIALOG_PERSISTSIZE );
    if ( dialog.open () == IDialogConstants.OK_ID )
    {
        final IResource resource = (IResource)dialog.getFirstResult ();
        if ( resource != null )
        {
            final String arg = resource.getFullPath ().toString ();
            final String fileLoc = VariablesPlugin.getDefault ().getStringVariableManager ().generateVariableExpression ( "workspace_loc", arg ); //$NON-NLS-1$
            this.fileText.setText ( fileLoc );
            makeDirty ();
        }
    }
}
 
Example 6
Project: convertigo-eclipse   File: SchemaObjectsDialog.java   Source Code and License 6 votes vote down vote up
@Override
protected void okPressed() {
	try {
		getButton(IDialogConstants.OK_ID).setEnabled(false);
		getButton(IDialogConstants.CANCEL_ID).setEnabled(false);
		
		if (schemaObjectsDialogComposite != null) {
			qname = (QName)schemaObjectsDialogComposite.getValue(null);
		}
		
		Thread thread = new Thread(this);
		thread.start();
	}
	catch (Throwable e) {
		ConvertigoPlugin.logException(e, "Unable to import objects");
	}
	finally {
		getButton(IDialogConstants.OK_ID).setEnabled(true);
		getButton(IDialogConstants.CANCEL_ID).setEnabled(true);
	}
}
 
Example 7
Project: convertigo-eclipse   File: XmlStructureDialog.java   Source Code and License 6 votes vote down vote up
@Override
protected void okPressed() {
	try {
		getButton(IDialogConstants.OK_ID).setEnabled(false);
		getButton(IDialogConstants.CANCEL_ID).setEnabled(false);
		
		if (schemaObjectsDialogComposite != null) {
			xml = (String)schemaObjectsDialogComposite.getValue(null);
		}
		
		Thread thread = new Thread(this);
		thread.start();
	}
	catch (Throwable e) {
		ConvertigoPlugin.logException(e, "Unable to import objects");
	}
	finally {
		getButton(IDialogConstants.OK_ID).setEnabled(true);
		getButton(IDialogConstants.CANCEL_ID).setEnabled(true);
	}
}
 
Example 8
Project: com.onpositive.prefeditor   File: FolderSelectionDialog.java   Source Code and License 6 votes vote down vote up
/**
 * Sets or clears the error message.
 * If not <code>null</code>, the OK button is disabled.
 * 
 * @param errorMessage
 *            the error message, or <code>null</code> to clear
 * @since 3.0
 */
public void setErrorMessage(String errorMessage) {
	this.errorMessage = errorMessage;
	if (errorMessageText != null && !errorMessageText.isDisposed()) {
		errorMessageText.setText(errorMessage == null ? " \n " : errorMessage); //$NON-NLS-1$
		// Disable the error message text control if there is no error, or
		// no error text (empty or whitespace only).  Hide it also to avoid
		// color change.
		// See https://bugs.eclipse.org/bugs/show_bug.cgi?id=130281
		boolean hasError = errorMessage != null && (StringConverter.removeWhiteSpaces(errorMessage)).length() > 0;
		errorMessageText.setEnabled(hasError);
		errorMessageText.setVisible(hasError);
		errorMessageText.getParent().update();
		// Access the ok button by id, in case clients have overridden button creation.
		// See https://bugs.eclipse.org/bugs/show_bug.cgi?id=113643
		Control button = getButton(IDialogConstants.OK_ID);
		if (button != null) {
			button.setEnabled(errorMessage == null);
		}
	}
}
 
Example 9
Project: Hydrograph   File: ParamterValueDialog.java   Source Code and License 6 votes vote down vote up
@Override
protected Control createButtonBar(Composite parent) {
	Composite composite = new Composite(parent, SWT.NONE);
	// create a layout with spacing and margins appropriate for the font
	// size.
	GridLayout layout = new GridLayout();
	layout.numColumns = 0; // this is incremented by createButton
	layout.makeColumnsEqualWidth = true;
	layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN );
	layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN - 4);
	layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
	layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING -2);
	
	composite.setLayout(layout);
	GridData data = new GridData(GridData.HORIZONTAL_ALIGN_END
			| GridData.VERTICAL_ALIGN_CENTER);
	
	composite.setLayoutData(data);
	composite.setFont(parent.getFont());
	
	// Add the buttons to the button bar.
	createButtonsForButtonBar(composite);
	return composite;
}
 
Example 10
Project: Hydrograph   File: FilterOperationClassUtility.java   Source Code and License 6 votes vote down vote up
/**
 * @param filterExtension
 * @param fileName
 * Open the dialog to browse .xml file for expression, operation or outputfields
 */
private void browseXMLSelectionDialog(String filterExtension, Text fileName) {
	String externalSchemaTextBoxValue = "";
	ExternalSchemaFileSelectionDialog dialog = new ExternalSchemaFileSelectionDialog("Project",
			"Select Input File (.xml)",  new String[]{filterExtension,Extensions.XML.toString()}, this);
	if (dialog.open() == IDialogConstants.OK_ID) {
		String file = fileNameTextBoxValue;
		IResource resource = (IResource) dialog.getFirstResult();
		String path[] = resource.getFullPath().toString().split("/");
		if (file.isEmpty()) {
			for (int i = 1; i < path.length; i++) {
				externalSchemaTextBoxValue = externalSchemaTextBoxValue + path[i] + "/";
			}
		} else {
			for (int i = 1; i < path.length; i++) {
				if (!path[i].endsWith(".xml")) {
					externalSchemaTextBoxValue = externalSchemaTextBoxValue + path[i] + "/";
				}
			}
			externalSchemaTextBoxValue = externalSchemaTextBoxValue + file;
		}
		fileName.setText(externalSchemaTextBoxValue);
	}
}
 
Example 11
Project: n4js   File: MultiElementListSelectionDialog.java   Source Code and License 5 votes vote down vote up
@Override
protected void createButtonsForButtonBar(Composite parent) {
	fBackButton = createButton(parent, IDialogConstants.BACK_ID, IDialogConstants.BACK_LABEL, false);

	// XXX: Workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=279425
	boolean HAS_BUG_279425 = true;
	fNextButton = createButton(parent, IDialogConstants.NEXT_ID, IDialogConstants.NEXT_LABEL, !HAS_BUG_279425);
	fFinishButton = createButton(parent, IDialogConstants.OK_ID, IDialogConstants.FINISH_LABEL, HAS_BUG_279425);

	createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
}
 
Example 12
Project: n4js   File: MultiElementListSelectionDialog.java   Source Code and License 5 votes vote down vote up
@Override
protected void buttonPressed(int buttonId) {
	if (buttonId == IDialogConstants.BACK_ID) {
		turnPage(false);
	} else if (buttonId == IDialogConstants.NEXT_ID) {
		turnPage(true);
	} else {
		super.buttonPressed(buttonId);
	}
}
 
Example 13
Project: Hydrograph   File: HydrographInstallationDialog.java   Source Code and License 5 votes vote down vote up
protected void setButtonLayoutData(FontMetrics metrics, Control button,
		boolean visible) {
	GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
	int widthHint = Dialog.convertHorizontalDLUsToPixels(metrics,
			IDialogConstants.BUTTON_WIDTH);
	Point minSize = button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
	data.widthHint = Math.max(widthHint, minSize.x);
	data.exclude = !visible;
	button.setLayoutData(data);
}
 
Example 14
Project: n4js   File: N4JSBuilderPreferencePage.java   Source Code and License 5 votes vote down vote up
/**
 * This method has been copied and adapted from org.eclipse.xtext.ui.preferences.OptionsConfigurationBlock.
 */
@Override
protected boolean processChanges(IWorkbenchPreferenceContainer container) {
	boolean needsBuild = !getPreferenceChanges().isEmpty() | projectSpecificChanged;
	boolean doBuild = false;
	if (needsBuild) {
		int count = getRebuildCount();
		if (count > rebuildCount) {
			needsBuild = false;
			rebuildCount = count;
		}
	}
	if (needsBuild) {
		String[] strings = getFullBuildDialogStrings(project == null);
		if (strings != null) {
			MessageDialog dialog = new MessageDialog(this.getShell(), strings[0], null, strings[1],
					MessageDialog.QUESTION,
					new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL,
							IDialogConstants.CANCEL_LABEL },
					2);
			int res = dialog.open();
			if (res == 0) {
				doBuild = true;
			} else if (res != 1) {
				return false;
			}
		}
	}
	if (container != null) {
		if (doBuild) {
			incrementRebuildCount();
			container.registerUpdateJob(getBuildJob(getProject()));
		}
	} else {
		if (doBuild) {
			getBuildJob(getProject()).schedule();
		}
	}
	return true;
}
 
Example 15
Project: n4js   File: AbstractExportToSingleFileWizardPage.java   Source Code and License 5 votes vote down vote up
/**
 * Displays a Yes/No question to the user with the specified message and returns the user's response.
 *
 * @param message
 *            the question to ask
 * @return <code>true</code> for Yes, and <code>false</code> for No
 */
private boolean queryYesNoQuestion(String message) {
	MessageDialog dialog = new MessageDialog(getContainer().getShell(),
			IDEWorkbenchMessages.Question,
			(Image) null, message, MessageDialog.NONE,
			new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0) {
		@Override
		protected int getShellStyle() {
			return super.getShellStyle() | SWT.SHEET;
		}
	};
	return dialog.open() == 0;
}
 
Example 16
Project: Hydrograph   File: HydrographInstallationDialog.java   Source Code and License 5 votes vote down vote up
public void update(String currentPageId) {
	if (composite == null || composite.isDisposed())
		return;
	GC metricsGC = new GC(composite);
	FontMetrics metrics = metricsGC.getFontMetrics();
	metricsGC.dispose();
	List buttons = (List) buttonMap.get(currentPageId);
	Control[] children = composite.getChildren();

	int visibleChildren = 0;
	Button closeButton = getButton(IDialogConstants.CLOSE_ID);

	for (int i = 0; i < children.length; i++) {
		Control control = children[i];
		if (closeButton == control)
			closeButton.dispose();
		else {
			control.setVisible(false);
			setButtonLayoutData(metrics, control, false);
		}
	}
	if (buttons != null) {
		for (int i = 0; i < buttons.size(); i++) {
			Button button = (Button) buttons.get(i);
			button.setVisible(true);
			setButtonLayoutData(metrics, button, true);
			GridData data = (GridData) button.getLayoutData();
			data.exclude = false;
			visibleChildren++;
		}
	}

	GridLayout compositeLayout = (GridLayout) composite.getLayout();
	compositeLayout.numColumns = visibleChildren;
	composite.layout(true);
}
 
Example 17
Project: ide-plugins   File: FunctionSWT.java   Source Code and License 5 votes vote down vote up
@Override
protected void createButtonsForButtonBar(Composite parent) {
    super.createButtonsForButtonBar(parent);

    Button ok = getButton(IDialogConstants.OK_ID);
    ok.setText("Create");
    ok.setEnabled(false);
    setButtonLayoutData(ok);

    Button cancel = getButton(IDialogConstants.CANCEL_ID);
    cancel.setText("Cancel");
    setButtonLayoutData(cancel);
    cancel.addListener(SWT.Selection, e -> {
        function.setFunctionName(null);
        function.setPackageName(null);
    });
}
 
Example 18
Project: ide-plugins   File: CodeSWT.java   Source Code and License 5 votes vote down vote up
private void restoreDialog(List<String> functionsList) {
    display.asyncExec(() -> { 
        composite.getParent().setCursor(new Cursor(display, SWT.CURSOR_ARROW));
        enableControls(true);
        if (functionsList == null || functionsList.isEmpty()) {
            errorLabel.setVisible(true);
        } else {
            functionsBox.setItems(functionsList.stream().toArray(size -> new String[size]));
            errorLabel.setVisible(false);
        }
        getButton(IDialogConstants.OK_ID).setEnabled(! errorLabel.isVisible());
    });
}
 
Example 19
Project: Hydrograph   File: WizardNewProjectCreationPage.java   Source Code and License 5 votes vote down vote up
private GridLayout initGridLayout(GridLayout layout, boolean margins) {
	layout.horizontalSpacing= convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
	layout.verticalSpacing= convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
	if (margins) {
		layout.marginWidth= convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
		layout.marginHeight= convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
	} else {
		layout.marginWidth= 0;
		layout.marginHeight= 0;
	}
	return layout;
}
 
Example 20
Project: Hydrograph   File: ViewDataPreferencesDialog.java   Source Code and License 5 votes vote down vote up
/**
 * Create contents of the button bar.
 * 
 * @param parent
 */
@Override
protected void createButtonsForButtonBar(Composite parent) {
	parent.setLayout(new GridLayout(1, false));
	Composite composite = new Composite(parent, SWT.NONE);
	composite.setLayout(new GridLayout(2, false));
	composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));

	warningImageLabel = new Label(composite, SWT.NONE);
	warningImageLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, true, 1, 1));
	
	warningImageLabel.setImage(ImagePathConstant.WARNING_ICON.getImageFromRegistry());

	warningLabel = new Label(composite, SWT.NONE);
	warningLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, true, true, 1, 1));
	warningLabel.setText(Messages.WARNING_MESSAGE);

	warningLabel.setVisible(false);
	warningImageLabel.setVisible(false);
	if (!delimiterTextBox.getText().equalsIgnoreCase(",")
			|| !quoteCharactorTextBox.getText().equalsIgnoreCase("\"")) {
		warningImageLabel.setVisible(true);
		warningLabel.setVisible(true);
	}
	createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
	createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
}
 
Example 21
Project: ide-plugins   File: ApplicationsSWT.java   Source Code and License 5 votes vote down vote up
private void enableControls(boolean enable) {
    currentAppBox.setEnabled(enable);
    keyText.setEnabled(enable);
    secretText.setEnabled(enable);
    logout.setEnabled(enable);
    getButton(IDialogConstants.OK_ID).setEnabled(enable);
}
 
Example 22
Project: android-uiautomatorviewer   File: OpenDialog.java   Source Code and License 5 votes vote down vote up
/**
 * Create contents of the button bar.
 */
@Override
protected void createButtonsForButtonBar(Composite parent) {
  mOkButton = createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
  createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
  updateButtonState();
}
 
Example 23
Project: Hydrograph   File: TransformDialog.java   Source Code and License 5 votes vote down vote up
/**
 * Create contents of the button bar.
 * 
 * @param parent
 */
@Override
protected void createButtonsForButtonBar(Composite parent) {
	Button okButton = createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
	Button cancelButton = createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
	propertyDialogButtonBar.setPropertyDialogButtonBar(okButton, null, cancelButton);
}
 
Example 24
Project: neoscada   File: KeySelectorDialog.java   Source Code and License 5 votes vote down vote up
@Override
protected void createButtonsForButtonBar ( final Composite parent )
{
    super.createButtonsForButtonBar ( parent );

    this.unlockButton = createButton ( parent, IDialogConstants.INTERNAL_ID, Messages.KeySelectorDialog_ButtonUnlock_Text, false );
}
 
Example 25
Project: neoscada   File: KeySelectorDialog.java   Source Code and License 5 votes vote down vote up
@Override
protected void buttonPressed ( final int buttonId )
{
    if ( buttonId == IDialogConstants.INTERNAL_ID )
    {
        performUnlock ( this.lockable );
    }
    super.buttonPressed ( buttonId );
}
 
Example 26
Project: neoscada   File: KeySelectorDialog.java   Source Code and License 5 votes vote down vote up
protected void updateButtons ()
{
    final Button ok = getButton ( IDialogConstants.OK_ID );
    if ( ok != null )
    {
        ok.setEnabled ( hasKeySelected () );
    }
    this.unlockButton.setEnabled ( this.lockable != null && this.lockable.isLocked () );
}
 
Example 27
Project: neoscada   File: DataItemDetailsDialog.java   Source Code and License 5 votes vote down vote up
@Override
protected void buttonPressed ( final int buttonId )
{
    if ( buttonId == IDialogConstants.CLOSE_ID )
    {
        closePressed ();
    }
}
 
Example 28
Project: neoscada   File: ConfirmationDialogFuture.java   Source Code and License 5 votes vote down vote up
private Boolean showDialog ( final ConfirmationCallback cb, final Display display, final Shell parentShell, final String dialogTitle )
{
    switch ( cb.getConfirmationType () )
    {
        case CONFIRM:
            return MessageDialog.openConfirm ( parentShell, dialogTitle, cb.getLabel () ) ? true : null;
        case ERROR:
            MessageDialog.openError ( parentShell, dialogTitle, cb.getLabel () );
            return true;
        case WARNING:
            MessageDialog.openWarning ( parentShell, dialogTitle, cb.getLabel () );
            return true;
        case INFORMATION:
            MessageDialog.openInformation ( parentShell, dialogTitle, cb.getLabel () );
            return true;
        case QUESTION:
            return MessageDialog.openQuestion ( parentShell, dialogTitle, cb.getLabel () );
        case QUESTION_WITH_CANCEL:
        {
            final MessageDialog dialog = new MessageDialog ( parentShell, dialogTitle, null, cb.getLabel (), MessageDialog.QUESTION_WITH_CANCEL, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }, 0 );
            final int result = dialog.open ();
            if ( result == 2 /*CANCEL*/)
            {
                return null;
            }
            else
            {
                return result == Window.OK;
            }
        }
        default:
            throw new IllegalArgumentException ( String.format ( "Unable to process type: %s", cb.getConfirmationType () ) );
    }
}
 
Example 29
Project: convertigo-eclipse   File: ProjectChooseTestCasesDialog.java   Source Code and License 5 votes vote down vote up
@Override
	protected Control createButtonBar(Composite parent) {
		Control buttonBar =  super.createButtonBar(parent);
		getButton(IDialogConstants.OK_ID).setText("OK");
//		getButton(IDialogConstants.OK_ID).setEnabled(false);
		getButton(IDialogConstants.CANCEL_ID).setText("Cancel");
		return buttonBar;
	}
 
Example 30
Project: convertigo-eclipse   File: ProjectDeployDialog.java   Source Code and License 5 votes vote down vote up
@Override
protected Control createButtonBar(Composite parent) {
	Control buttonBar =  super.createButtonBar(parent);
	projectDeployDialogComposite = (ProjectDeployDialogComposite) dialogComposite;		
	getButton(IDialogConstants.OK_ID).setText("Deploy");
	projectDeployDialogComposite.setOkButton(getButton(IDialogConstants.OK_ID));
	return buttonBar;
}
 
Example 31
Project: Hydrograph   File: JdkPathDialog.java   Source Code and License 5 votes vote down vote up
/**
 * Create contents of the button bar.
 * @param parent
 */
@Override
protected void createButtonsForButtonBar(Composite parent) {
	parent.setLayout(new GridLayout(3,false));
	parent.setLayoutData(new GridData(SWT.FILL,SWT.BOTTOM,true,true));
	createErrorLabel(parent);
okButton = createButton(parent, IDialogConstants.OK_ID, "Save and &Restart", true);
okButton.setEnabled(false);
createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
}
 
Example 32
Project: convertigo-eclipse   File: WsReferenceImportDialog.java   Source Code and License 5 votes vote down vote up
protected void okPressed() {		
	try {
		progressBar = ( (WsReferenceImportDialogComposite)dialogComposite ).progressBar;
		
		getButton(IDialogConstants.OK_ID).setEnabled(false);
		getButton(IDialogConstants.CANCEL_ID).setEnabled(false);

		Thread thread = new Thread(this);
		thread.start();
	}
	catch (Throwable e) {
		ConvertigoPlugin.logException(e, "Unable to import WS reference!");
	}
}
 
Example 33
Project: convertigo-eclipse   File: SchemaObjectsDialog.java   Source Code and License 5 votes vote down vote up
@Override
protected Control createButtonBar(Composite parent) {
	Control buttonBar =  super.createButtonBar(parent);
	getButton(IDialogConstants.OK_ID).setText("Import");
	getButton(IDialogConstants.OK_ID).setEnabled(false);
	return buttonBar;
}
 
Example 34
Project: convertigo-eclipse   File: ProjectVersionUpdateDialog.java   Source Code and License 5 votes vote down vote up
@Override
protected Control createButtonBar(Composite parent) {
	Control buttonBar =  super.createButtonBar(parent);
	getButton(IDialogConstants.OK_ID).setText("Update");
	getButton(IDialogConstants.OK_ID).setEnabled(false);
	Button cancel = getButton(IDialogConstants.CANCEL_ID);
	cancel.setText("Skip");
	cancel.setFocus();
	return buttonBar;
}
 
Example 35
Project: Hydrograph   File: RunConfigDialog.java   Source Code and License 5 votes vote down vote up
/**
 * Create contents of the button bar.
 * 
 * @param parent
 */
@Override
protected void createButtonsForButtonBar(Composite parent) {
	okButton = createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
	createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
	
	applyServerDetailsCrossTextEmptyValidationListener(txtEdgeNode);
	applyServerDetailsCrossTextEmptyValidationListener(txtPassword);
	applyServerDetailsCrossTextEmptyValidationListener(txtUserName);
	applyServerDetailsCrossTextEmptyValidationListener(txtBasePath);
	applyServerDetailsCrossTextEmptyValidationListener(txtKeyFile);
	applyServerDetailsCrossTextEmptyValidationListener(txtRunUtility);
	applyServerDetailsCrossTextEmptyValidationListener(txtProjectPath);
	loadBuildProperties();
}
 
Example 36
Project: convertigo-eclipse   File: XmlStructureDialog.java   Source Code and License 5 votes vote down vote up
@Override
protected Control createButtonBar(Composite parent) {
	Control buttonBar =  super.createButtonBar(parent);
	getButton(IDialogConstants.OK_ID).setText("Import");
	getButton(IDialogConstants.OK_ID).setEnabled(true);
	return buttonBar;
}
 
Example 37
Project: Hydrograph   File: FilterLogicWidget.java   Source Code and License 5 votes vote down vote up
private void addSelectionListerner() {
	button.addSelectionListener(new SelectionAdapter() {
		@Override
		public void widgetSelected(SelectionEvent e) {
			FilterLogicDataStructure clonedDataStructure = (FilterLogicDataStructure) dataStructure.clone();
			FilterExpressionOperationDialog dialog = new FilterExpressionOperationDialog(
					Display.getCurrent().getActiveShell(), clonedDataStructure, getComponent(),
					propertyDialogButtonBar, widgetConfig, getInputSchema());
			
			if (StringUtils.equalsIgnoreCase(getComponent().getComponentName(), Constants.FILTER)) {
				dialog.setTitle("Filter Editor");
			} else if (StringUtils.equalsIgnoreCase(getComponent().getComponentName(),
					Constants.PARTITION_BY_EXPRESSION)) {
				dialog.setTitle("Partition Logic Editor");
			}

			if (dialog.open() == IDialogConstants.OK_ID) {
				dataStructure=clonedDataStructure;
			}
			showHideErrorSymbol(widgets);
			
			if(dialog.isYesButtonPressed()) {
				propertyDialog.pressOK();
			}
			else if(dialog.isNoButtonPressed()) {
				propertyDialog.pressCancel();
			}
		}
	});
}
 
Example 38
Project: convertigo-eclipse   File: StatisticsDialog.java   Source Code and License 5 votes vote down vote up
/**
 * Create contents of the button bar.
 * 
 * @param parent
 */
@Override
protected void createButtonsForButtonBar(Composite parent) {
	Button buttonOk = createButton(parent, IDialogConstants.OK_ID, "OK",
			true);
	buttonOk.setEnabled(true);
}
 
Example 39
Project: Hydrograph   File: JoinMapGrid.java   Source Code and License 5 votes vote down vote up
/**
 * Create contents of the button bar.
 * 
 * @param parent
 */
@Override
protected void createButtonsForButtonBar(Composite parent) {
	
	okButton = createButton(parent, IDialogConstants.OK_ID,
			IDialogConstants.OK_LABEL, true);

	createButton(parent, IDialogConstants.CANCEL_ID,
			IDialogConstants.CANCEL_LABEL, false);
	
}
 
Example 40
Project: Equella   File: NewJPFRegistryWizardPageOne.java   Source Code and License 5 votes vote down vote up
private GridLayout initGridLayout(GridLayout layout, boolean margins)
{
	layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
	layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
	if( margins )
	{
		layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
		layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
	}
	else
	{
		layout.marginWidth = 0;
		layout.marginHeight = 0;
	}
	return layout;
}
 
Example 41
Project: gw4e.project   File: GW4ELaunchConfigurationTab.java   Source Code and License 5 votes vote down vote up
/**
 * A helper method to size the button
 * 
 * @param button
 * @return
 */
public static int getButtonWidthHint(Button button) {
	button.setFont(JFaceResources.getDialogFont());
	PixelConverter converter = new PixelConverter(button);
	int widthHint = converter.convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
	return Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);
}
 
Example 42
Project: gw4e.project   File: GW4ELaunchConfigurationTab.java   Source Code and License 5 votes vote down vote up
/**
 * A helper method to size the button
 * 
 * @param button
 * @return
 */
public static int getButtonWidthHint(Button button) {
	button.setFont(JFaceResources.getDialogFont());
	PixelConverter converter = new PixelConverter(button);
	int widthHint = converter.convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
	return Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);
}
 
Example 43
Project: gw4e.project   File: DialogManager.java   Source Code and License 5 votes vote down vote up
public static MessageDialogWithToggle createRememberDecisonDialog(String title, String text, String toggletext,
		Runnable okRunnable) {
	final String[] buttons = new String[] { IDialogConstants.CLOSE_LABEL, IDialogConstants.OK_LABEL, };

	return new MessageDialogWithToggle(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), title,
			null, text, MessageDialog.QUESTION, buttons, 0, toggletext, false) {
		protected void buttonPressed(int buttonId) {
			if (okRunnable != null && IDialogConstants.OK_ID == buttonId) {
				okRunnable.run();
				return;
			}
			super.buttonPressed(buttonId);
		}
	};
}
 
Example 44
Project: pgcodekeeper   File: FilterDialog.java   Source Code and License 5 votes vote down vote up
@Override
protected void createButtonsForButtonBar(Composite parent) {
    createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
    Button btnReset = createButton(parent, IDialogConstants.NO_ID, Messages.FilterDialog_reset, false);
    createButton(parent, IDialogConstants.CANCEL_ID, Messages.FilterDialog_cancel, false);

    btnReset.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            text.setText(""); //$NON-NLS-1$
            btnRegEx.setSelection(false);
            objViewer.setAllChecked(false);
            chgViewer.setAllChecked(false);
        }
    });
}
 
Example 45
Project: pgcodekeeper   File: ProjectEditorDiffer.java   Source Code and License 5 votes vote down vote up
private void askPerspectiveChange(IEditorSite site) {
    String mode = mainPrefs.getString(PG_EDIT_PREF.PERSPECTIVE_CHANGING_STATUS);
    // if select "YES" with toggle
    if (mode.equals(MessageDialogWithToggle.ALWAYS)){
        changePerspective(site);
        // if not select "NO" with toggle, show choice message dialog
    } else if (!mode.equals(MessageDialogWithToggle.NEVER)){
        MessageDialogWithToggle dialog = MessageDialogWithToggle.openYesNoQuestion(site.getShell(),
                Messages.change_perspective_title, Messages.change_perspective_message,
                Messages.remember_choice_toggle, false, mainPrefs, PG_EDIT_PREF.PERSPECTIVE_CHANGING_STATUS);
        if(dialog.getReturnCode() == IDialogConstants.YES_ID){
            changePerspective(site);
        }
    }
}
 
Example 46
Project: com.onpositive.prefeditor   File: ComboDialog.java   Source Code and License 5 votes vote down vote up
@Override
protected void createButtonsForButtonBar(Composite parent) {
	super.createButtonsForButtonBar(parent);

	// If the initial selection is invalid, disable the OK button.
	boolean okEnabled = false;
	if (comboText != null) {
		okEnabled = (validateSelection(comboText) != null);
	} else if (!allowedValueList.isEmpty()) {
		okEnabled = true;
	}
	getButton(IDialogConstants.OK_ID).setEnabled(okEnabled);

	return;
}
 
Example 47
Project: bdf2   File: PropertyBrowser.java   Source Code and License 5 votes vote down vote up
protected void buttonPressed(int buttonId) {
	if (IDialogConstants.OK_ID == buttonId) {
		okPressed();
	} else if (IDialogConstants.CANCEL_ID == buttonId) {
		cancelPressed();
	} else if (UPDATE_ID == buttonId) {

		Display.getDefault().asyncExec(new Runnable() {

			@Override
			public void run() {
				try {
					propEditor.updatePropertyBrowser();
					treeViewer.setInput(XmlReader.loadXmlReader(path));
				} catch (Exception e) {
					e.printStackTrace();
					// TODO: handle exception
				} finally {
					treeViewer.refresh();
				}
			}
		});
	}
}
 
Example 48
Project: com.onpositive.prefeditor   File: FolderSelectionDialog.java   Source Code and License 5 votes vote down vote up
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
    viewer.getControl().setFocus();
    loadPrevChoices();
    viewer.setInput(prevFolders.toArray(new String[0]));
    if (value != null) {
    	viewer.setSelection(new StructuredSelection(value));
    }
}
 
Example 49
Project: Hydrograph   File: ELTLookupConfigGrid.java   Source Code and License 5 votes vote down vote up
/**
 * Create contents of the button bar.
 * 
 * @param parent
 */
@Override
protected void createButtonsForButtonBar(Composite parent) {
	Button button = createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
	button.addSelectionListener(new SelectionAdapter() {
		@Override
		public void widgetSelected(SelectionEvent e) {

		}
	});
	createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
}
 
Example 50
Project: com.onpositive.prefeditor   File: NewPreferenceDialog.java   Source Code and License 5 votes vote down vote up
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
      nameText.setFocus();
      if (name != null) {
          nameText.setText(name);
      }
      if (value != null) {
          valueText.setText(value);
      }
      viewer.setInput(possibleParents);
      if (this.parent != null) {
      	viewer.setSelection(new StructuredSelection(this.parent));
      }
      viewer.addSelectionChangedListener(new ISelectionChangedListener() {
	
	@Override
	public void selectionChanged(
			SelectionChangedEvent event) {
		parentSelected(valueFromSelection(event.getSelection()));
		validateInput();
	}
});
      viewer.getControl().addListener(SWT.Modify, new Listener() {

	@Override
	public void handleEvent(Event arg0) {
		validateInput();
	}
      	
      });
  }
 
Example 51
Project: SWET   File: IconAndMessageDialogEx.java   Source Code and License 5 votes vote down vote up
protected void createButtonsForButtonBar(Composite parent) {
	createButton(parent, IDialogConstants.YES_ID, IDialogConstants.YES_LABEL,
			true);
	createButton(parent, IDialogConstants.NO_ID, IDialogConstants.NO_LABEL,
			false);
	createButton(parent, I_DUNNO_ID, I_DUNNO_LABEL, false);
}
 
Example 52
Project: Hydrograph   File: MultiParameterFileDialog.java   Source Code and License 5 votes vote down vote up
/**
 * Create contents of the button bar.
 * 
 * @param parent
 */
@Override
protected void createButtonsForButtonBar(Composite parent) {
	 Button okButton = createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL,true);
	okButton.setFocus();
	applyButton = createButton(parent, IDialogConstants.NO_ID, "Apply", false);
	applyButton.setEnabled(false);
	createButton(parent, IDialogConstants.CANCEL_ID,IDialogConstants.CANCEL_LABEL, false);
}
 
Example 53
Project: bdf2   File: DbTableRelationDialog.java   Source Code and License 5 votes vote down vote up
@Override
protected void initializeBounds() {
	super.initializeBounds();
	buttonOk = getButton(IDialogConstants.OK_ID);
	buttonOk.setText("确定");
	buttonCancel = getButton(IDialogConstants.CANCEL_ID);
	buttonCancel.setText("取消");
}
 
Example 54
Project: bdf2   File: DbDriverLocationDialog.java   Source Code and License 5 votes vote down vote up
@Override
protected void initializeBounds() {
	super.initializeBounds();
	buttonOk = getButton(IDialogConstants.OK_ID);
	buttonOk.setText("确定");
	buttonCancel = getButton(IDialogConstants.CANCEL_ID);
	buttonCancel.setText("取消");
}
 
Example 55
Project: Hydrograph   File: ELTLookupMapWizard.java   Source Code and License 5 votes vote down vote up
/**
 * Create contents of the button bar.
 * 
 * @param parent
 */
@Override
protected void createButtonsForButtonBar(Composite parent) {
	okButton = createButton(parent, IDialogConstants.OK_ID,
			IDialogConstants.OK_LABEL, true);
	createButton(parent, IDialogConstants.CANCEL_ID,
			IDialogConstants.CANCEL_LABEL, false);
}
 
Example 56
Project: Hydrograph   File: JobHandler.java   Source Code and License 5 votes vote down vote up
private boolean jobIsSaved(){
	ELTGraphicalEditor editor = SubJobUtility.getCurrentEditor();
	if(editor.isDirty())
	{
		if(!StringUtils.equals(Activator.getDefault().getPreferenceStore().getString(JobRunPreference.SAVE_JOB_BEFORE_RUN_PREFRENCE), MessageDialogWithToggle.ALWAYS)){
		SaveJobFileBeforeRunDialog messageBox = new SaveJobFileBeforeRunDialog(Display.getCurrent().getActiveShell(),"'"+editor.getEditorInput().getName()+"' "+Messages.CONFIRM_TO_SAVE_JOB_BEFORE_RUN );
	    int rc = messageBox.open();
	    if(rc!=IDialogConstants.OK_ID){
	    	return false;
	    	}
	    }
	PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor().doSave(null);	    
	}
	return true;
}
 
Example 57
Project: openaudible   File: GridComposite.java   Source Code and License 5 votes vote down vote up
/**
 * Set the layout data of the button to a GridData with appropriate heights and widths.
 *
 * @param button The button to set the layoutdata
 * @param data   The GridData to use
 */
protected static void setButtonLayoutData(Button button, GridData data) {
    /* GC to retrieve fontmetrics object */
    GC gc = new GC(button);
    FontMetrics fontMetrics = gc.getFontMetrics();
    /* Apply appropiate gridata */
    int widthHint = Dialog.convertHorizontalDLUsToPixels(fontMetrics, IDialogConstants.BUTTON_WIDTH);
    data.widthHint = Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);
    button.setLayoutData(data);
    /* Dispose GC */
    gc.dispose();
}
 
Example 58
Project: Hydrograph   File: FilterOperationClassUtility.java   Source Code and License 5 votes vote down vote up
/**
	 * Open selection dialog for Java files, File selection restricted to ".java" extension.
	 * @param filterExtension
	 * @param fileName
	 */
	public static void browseJavaSelectionDialog(String filterExtension, Text fileName) {
		ResourceFileSelectionDialog dialog = new ResourceFileSelectionDialog(
				"Project", "Select Java Class (.java)", new String[] { filterExtension });
		if (dialog.open() == IDialogConstants.OK_ID) {
			IResource resource = (IResource) dialog.getFirstResult();
			String filePath = resource.getRawLocation().toOSString();
			java.nio.file.Path path =Paths.get(filePath); 
			String classFile=path.getFileName().toString();
			String name = "";
			try(BufferedReader reader= new BufferedReader(new FileReader(filePath))){ 
				String firstLine= reader.readLine();
				if(firstLine.contains(Constants.PACKAGE)){
					name= firstLine.replaceFirst(Constants.PACKAGE, "").replace(";", "");
					if(!name.equalsIgnoreCase("")){
						name=name+"."+classFile.substring(0, classFile.lastIndexOf('.'));
					}
					
				}else{
					name=classFile.substring(0, classFile.lastIndexOf('.'));
				}
				
			} catch (IOException e) { 
				logger.error("Unable to read file " + filePath,e );
			}
			fileName.setText(name.trim());
			filePath = resource.getRawLocation().toOSString();
			fileName.setData("path", resource.getFullPath().toString());
}
	}
 
Example 59
Project: Hydrograph   File: FilterOperationClassUtility.java   Source Code and License 5 votes vote down vote up
/**
 * Open selection dialog for job files, File selection restricted to ".job" extension.
 * @param filterExtension
 * @param fileName
 */
private void browseJobSelectionDialog(String filterExtension, Text fileName) {
	ResourceFileSelectionDialog dialog = new ResourceFileSelectionDialog(
			"Project", "Select Sub Job (.job)", new String[] { filterExtension });
	if (dialog.open() == IDialogConstants.OK_ID) {
		IResource resource = (IResource) dialog.getFirstResult();
		String filePath = resource.getFullPath().toString();
		if(isFileExistsOnLocalFileSystem(new Path(filePath), fileName)){
			fileName.setText(filePath.substring(1));
		}
	}
}
 
Example 60
Project: Hydrograph   File: HiveInputExtractMetaStoreDialog.java   Source Code and License 5 votes vote down vote up
/**
 * Create contents of the button bar.
 * @param parent
 */
@Override
protected void createButtonsForButtonBar(Composite parent) {
	
	
	
	createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL,
			true);
	createButton(parent, IDialogConstants.CANCEL_ID,
			IDialogConstants.CANCEL_LABEL, false);
}