org.eclipse.jface.util.Policy Java Examples

The following examples show how to use org.eclipse.jface.util.Policy. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TSWizardDialog.java    From translationstudio8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Closes this window.
 * 
 * @return <code>true</code> if the window is (or was already) closed, and
 *         <code>false</code> if it is still open
 */
private boolean hardClose() {
	// inform wizards
	for (int i = 0; i < createdWizards.size(); i++) {
		IWizard createdWizard = (IWizard) createdWizards.get(i);
		try {
			createdWizard.dispose();
		} catch (Exception e) {
			Status status = new Status(IStatus.ERROR, Policy.JFACE, IStatus.ERROR, e.getMessage(), e);
			Policy.getLog().log(status);
		}
		// Remove this dialog as a parent from the managed wizard.
		// Note that we do this after calling dispose as the wizard or
		// its pages may need access to the container during
		// dispose code
		createdWizard.setContainer(null);
	}
	// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=202534
	// disposing the wizards could cause the image currently set in
	// this dialog to be disposed.  A subsequent repaint event during
	// close would then fail.  To prevent this case, we null out the image.
	setTitleImage(null);
	return super.close();
}
 
Example #2
Source File: TSWizardDialog.java    From tmxeditor8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Closes this window.
 * 
 * @return <code>true</code> if the window is (or was already) closed, and
 *         <code>false</code> if it is still open
 */
private boolean hardClose() {
	// inform wizards
	for (int i = 0; i < createdWizards.size(); i++) {
		IWizard createdWizard = (IWizard) createdWizards.get(i);
		try {
			createdWizard.dispose();
		} catch (Exception e) {
			Status status = new Status(IStatus.ERROR, Policy.JFACE, IStatus.ERROR, e.getMessage(), e);
			Policy.getLog().log(status);
		}
		// Remove this dialog as a parent from the managed wizard.
		// Note that we do this after calling dispose as the wizard or
		// its pages may need access to the container during
		// dispose code
		createdWizard.setContainer(null);
	}
	// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=202534
	// disposing the wizards could cause the image currently set in
	// this dialog to be disposed.  A subsequent repaint event during
	// close would then fail.  To prevent this case, we null out the image.
	setTitleImage(null);
	return super.close();
}
 
Example #3
Source File: NewJavaProjectWizardPageOne.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private void fillExecutionEnvironments(ComboDialogField comboField) {
	String selectedItem= getLastSelectedEE();
	int selectionIndex= -1;
	if (fUseEEJRE.isSelected()) {
		selectionIndex= comboField.getSelectionIndex();
		if (selectionIndex != -1) {// paranoia
			selectedItem= comboField.getItems()[selectionIndex];
		}
	}

	fInstalledEEs= JavaRuntime.getExecutionEnvironmentsManager().getExecutionEnvironments();
	Arrays.sort(fInstalledEEs, new Comparator<IExecutionEnvironment>() {
		public int compare(IExecutionEnvironment arg0, IExecutionEnvironment arg1) {
			return Policy.getComparator().compare(arg0.getId(), arg1.getId());
		}
	});
	selectionIndex= -1;//find new index
	String[] eeLabels= new String[fInstalledEEs.length];
	fEECompliance= new String[fInstalledEEs.length];
	for (int i= 0; i < fInstalledEEs.length; i++) {
		eeLabels[i]= fInstalledEEs[i].getId();
		if (selectedItem != null && eeLabels[i].equals(selectedItem)) {
			selectionIndex= i;
		}
		fEECompliance[i]= JavaModelUtil.getExecutionEnvironmentCompliance(fInstalledEEs[i]);
	}
	comboField.setItems(eeLabels);
	if (selectionIndex == -1) {
		comboField.selectItem(getDefaultEEName());
	} else {
		comboField.selectItem(selectedItem);
	}
}
 
Example #4
Source File: MainProjectWizardPage.java    From sarl with Apache License 2.0 5 votes vote down vote up
private void fillExecutionEnvironments(ComboDialogField comboField) {
	String selectedItem = getLastSelectedEE();
	int selectionIndex = comboField.getSelectionIndex();
	if (this.useEEJRE.isSelected()) {
		if (selectionIndex != -1) {
			// paranoia
			selectedItem = comboField.getItems()[selectionIndex];
		}
	}

	this.installedEEs = JavaRuntime.getExecutionEnvironmentsManager().getExecutionEnvironments();
	Arrays.sort(this.installedEEs, new Comparator<IExecutionEnvironment>() {
		@Override
		public int compare(IExecutionEnvironment arg0, IExecutionEnvironment arg1) {
			return Policy.getComparator().compare(arg0.getId(), arg1.getId());
		}
	});
	// find new index
	selectionIndex = -1;
	final String[] eeLabels = new String[this.installedEEs.length];
	this.eeCompliance = new String[this.installedEEs.length];
	for (int i = 0; i < this.installedEEs.length; i++) {
		eeLabels[i] = this.installedEEs[i].getId();
		if (selectedItem != null && eeLabels[i].equals(selectedItem)) {
			selectionIndex = i;
		}
		this.eeCompliance[i] = JavaModelUtil.getExecutionEnvironmentCompliance(this.installedEEs[i]);
	}
	comboField.setItems(eeLabels);
	if (selectionIndex == -1) {
		comboField.selectItem(getDefaultEEName());
	} else {
		comboField.selectItem(selectedItem);
	}
}
 
Example #5
Source File: ExtensibleWizard.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Override
 public void dispose() {
 	super.dispose();
 	 // notify pages
     for (int i = 0; i < additionalPages.size(); i++) {
try {
          ((IWizardPage) additionalPages.get(i)).dispose();
} catch (Exception e) {
	Status status = new Status(IStatus.ERROR, Policy.JFACE, IStatus.ERROR, e.getMessage(), e);
	Policy.getLog().log(status);
}
     }
 }
 
Example #6
Source File: NewJavaProjectWizardPageOne.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
private void fillInstalledJREs(ComboDialogField comboField) {
	String selectedItem= getLastSelectedJRE();
	int selectionIndex= -1;
	if (fUseProjectJRE.isSelected()) {
		selectionIndex= comboField.getSelectionIndex();
		if (selectionIndex != -1) {//paranoia
			selectedItem= comboField.getItems()[selectionIndex];
		}
	}

	fInstalledJVMs= getWorkspaceJREs();
	Arrays.sort(fInstalledJVMs, new Comparator<IVMInstall>() {

		public int compare(IVMInstall i0, IVMInstall i1) {
			if (i1 instanceof IVMInstall2 && i0 instanceof IVMInstall2) {
				String cc0= JavaModelUtil.getCompilerCompliance((IVMInstall2) i0, JavaCore.VERSION_1_4);
				String cc1= JavaModelUtil.getCompilerCompliance((IVMInstall2) i1, JavaCore.VERSION_1_4);
				int result= cc1.compareTo(cc0);
				if (result != 0)
					return result;
			}
			return Policy.getComparator().compare(i0.getName(), i1.getName());
		}

	});
	selectionIndex= -1;//find new index
	String[] jreLabels= new String[fInstalledJVMs.length];
	fJRECompliance= new String[fInstalledJVMs.length];
	for (int i= 0; i < fInstalledJVMs.length; i++) {
		jreLabels[i]= fInstalledJVMs[i].getName();
		if (selectedItem != null && jreLabels[i].equals(selectedItem)) {
			selectionIndex= i;
		}
		if (fInstalledJVMs[i] instanceof IVMInstall2) {
			fJRECompliance[i]= JavaModelUtil.getCompilerCompliance((IVMInstall2) fInstalledJVMs[i], JavaCore.VERSION_1_4);
		} else {
			fJRECompliance[i]= JavaCore.VERSION_1_4;
		}
	}
	comboField.setItems(jreLabels);
	if (selectionIndex == -1) {
		comboField.selectItem(getDefaultJVMName());
	} else {
		comboField.selectItem(selectedItem);
	}
}
 
Example #7
Source File: MainProjectWizardPage.java    From sarl with Apache License 2.0 4 votes vote down vote up
private void fillInstalledJREs(ComboDialogField comboField) {
	String selectedItem = getLastSelectedJRE();
	int selectionIndex = comboField.getSelectionIndex();
	if (this.useProjectJRE.isSelected()) {
		if (selectionIndex != -1) {
			// paranoia
			selectedItem = comboField.getItems()[selectionIndex];
		}
	}

	this.installedJVMs = getWorkspaceJREs();
	Arrays.sort(this.installedJVMs, new Comparator<IVMInstall>() {

		@Override
		public int compare(IVMInstall i0, IVMInstall i1) {
			if (i1 instanceof IVMInstall2 && i0 instanceof IVMInstall2) {
				final String cc0 = JavaModelUtil.getCompilerCompliance((IVMInstall2) i0,
						SARLVersion.MINIMAL_JDK_VERSION_IN_SARL_PROJECT_CLASSPATH);
				final String cc1 = JavaModelUtil.getCompilerCompliance((IVMInstall2) i1,
						SARLVersion.MINIMAL_JDK_VERSION_IN_SARL_PROJECT_CLASSPATH);
				final int result = cc1.compareTo(cc0);
				if (result != 0) {
					return result;
				}
			}
			return Policy.getComparator().compare(i0.getName(), i1.getName());
		}

	});
	// find new index
	selectionIndex = -1;
	final String[] jreLabels = new String[this.installedJVMs.length];
	this.jreCompliance = new String[this.installedJVMs.length];
	for (int i = 0; i < this.installedJVMs.length; i++) {
		jreLabels[i] = this.installedJVMs[i].getName();
		if (selectedItem != null && jreLabels[i].equals(selectedItem)) {
			selectionIndex = i;
		}
		if (this.installedJVMs[i] instanceof IVMInstall2) {
			this.jreCompliance[i] = JavaModelUtil.getCompilerCompliance(
					(IVMInstall2) this.installedJVMs[i],
					SARLVersion.MINIMAL_JDK_VERSION_IN_SARL_PROJECT_CLASSPATH);
		} else {
			this.jreCompliance[i] = SARLVersion.MINIMAL_JDK_VERSION_IN_SARL_PROJECT_CLASSPATH;
		}
	}
	comboField.setItems(jreLabels);
	if (selectionIndex == -1) {
		comboField.selectItem(getDefaultJVMName());
	} else {
		comboField.selectItem(selectedItem);
	}
}