org.eclipse.jface.dialogs.IDialogSettings Java Examples

The following examples show how to use org.eclipse.jface.dialogs.IDialogSettings. 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: ConcordanceSearchDialog.java    From tmxeditor8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Writes the given history into the given dialog store.
 * @param history
 *            the history
 * @param settings
 *            the dialog settings
 * @param sectionName
 *            the section name
 * @since 3.2
 */
private void writeHistory(List<String> history, IDialogSettings settings, String sectionName) {
	int itemCount = history.size();
	Set<String> distinctItems = new HashSet<String>(itemCount);
	for (int i = 0; i < itemCount; i++) {
		String item = (String) history.get(i);
		if (distinctItems.contains(item)) {
			history.remove(i--);
			itemCount--;
		} else {
			distinctItems.add(item);
		}
	}

	while (history.size() > 8) {
		history.remove(8);
	}

	String[] names = new String[history.size()];
	history.toArray(names);
	settings.put(sectionName, names);
}
 
Example #2
Source File: ImportProjectWizard.java    From tmxeditor8 with GNU General Public License v2.0 6 votes vote down vote up
/**
    * Constructor for ExternalProjectImportWizard.
    * 
    * @param initialPath Default path for wizard to import
    * @since 3.5
    */
public ImportProjectWizard(String initialPath)
   {
       super();
       this.initialPath = initialPath;
       setWindowTitle(DataTransferMessages.DataTransfer_importTitle);
       setNeedsProgressMonitor(true);
       IDialogSettings workbenchSettings = IDEWorkbenchPlugin.getDefault()
       		.getDialogSettings();
       
	IDialogSettings wizardSettings = workbenchSettings
	        .getSection(IMPORT_PROJECT_SECTION);
	if (wizardSettings == null) {
		wizardSettings = workbenchSettings
	            .addNewSection(IMPORT_PROJECT_SECTION);
	}
	setDialogSettings(wizardSettings);        
   }
 
Example #3
Source File: JarOptionsPage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
/**
 *	Initializes the JAR package from last used wizard page values.
 */
protected void initializeJarPackage() {
	IDialogSettings settings= getDialogSettings();
	if (settings != null) {
		fJarPackage.setExportWarnings(settings.getBoolean(STORE_EXPORT_WARNINGS));
		fJarPackage.setExportErrors(settings.getBoolean(STORE_EXPORT_ERRORS));
		fJarPackage.setUseSourceFolderHierarchy(settings.getBoolean(STORE_USE_SRC_FOLDERS));
		fJarPackage.setSaveDescription(false); // bug 15877
		String pathStr= settings.get(STORE_DESCRIPTION_LOCATION);
		if (pathStr == null)
			pathStr= ""; //$NON-NLS-1$
		fJarPackage.setDescriptionLocation(new Path(pathStr));
		if (settings.get(STORE_BUILD_IF_NEEDED) != null)
			fJarPackage.setBuildIfNeeded(settings.getBoolean(STORE_BUILD_IF_NEEDED));
	}
}
 
Example #4
Source File: JarPackageWizard.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public boolean performFinish() {
	fJarPackage.setElements(fJarPackageWizardPage.getSelectedElementsWithoutContainedChildren());

	if (!executeExportOperation(fJarPackage.createJarExportRunnable(getShell())))
		return false;

	// Save the dialog settings
	if (fHasNewDialogSettings) {
		IDialogSettings workbenchSettings= JavaPlugin.getDefault().getDialogSettings();
		IDialogSettings section= workbenchSettings.getSection(DIALOG_SETTINGS_KEY);
		section= workbenchSettings.addNewSection(DIALOG_SETTINGS_KEY);
		setDialogSettings(section);
	}
	IWizardPage[] pages= getPages();
	for (int i= 0; i < getPageCount(); i++) {
		IWizardPage page= pages[i];
		if (page instanceof IJarPackageWizardPage)
			((IJarPackageWizardPage) page).finish();
	}
	return true;
}
 
Example #5
Source File: SelectArtifactToDeployPage.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void loadSettings(IDialogSettings settings) {
    IDialogSettings section = settings.getSection(repositoryModel.getName());
    if (section != null && section.getArray(DEPLOY_DEFAULT_SELECTION) != null) {
        if (defaultSelectedElements == null || defaultSelectedElements.isEmpty()) {
            defaultSelectedElements = fromStrings(section.getArray(DEPLOY_DEFAULT_SELECTION));
        }
        cleanBDM = section.getBoolean(CLEAN_BDM_DEFAULT_SELECTION);
        validate = section.getBoolean(VALIDATE_DEFAULT_SELECTION);
        latestVersionOnly = section.getBoolean(ONLY_LATEST_PROCESS_VERSION_SELECTION);
    }
    String activeEnvironment = ConfigurationPlugin.getDefault().getPreferenceStore()
            .getString(ConfigurationPreferenceConstants.DEFAULT_CONFIGURATION);
    environment = environmentProvider.getEnvironment().contains(activeEnvironment) ? activeEnvironment
            : ConfigurationPreferenceConstants.LOCAL_CONFIGURAITON;
}
 
Example #6
Source File: RefactoringLocationControl.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Saves the history of this control.
 */
public void saveHistory() {
	final IDialogSettings settings= fWizard.getDialogSettings();
	if (settings != null) {
		final LinkedList<String> locations= new LinkedList<String>();
		final String[] items= fCombo.getItems();
		for (int index= 0; index < items.length; index++)
			locations.add(items[index]);
		final String text= fCombo.getText().trim();
		if (!"".equals(text)) { //$NON-NLS-1$
			locations.remove(text);
			locations.addFirst(text);
		}
		final int size= locations.size();
		for (int index= 0; index < size - MAX_HISTORY_SIZE; index++)
			locations.removeLast();
		settings.put(fKey, locations.toArray(new String[locations.size()]));
	}
}
 
Example #7
Source File: ExportRepositoryWizardPage.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Hook method for saving widget values for restoration by the next instance
 * of this class.
 */
protected void saveWidgetValues() {
    // update directory names history
    final IDialogSettings settings = getDialogSettings();
    if (settings != null) {
        String[] directoryNames = settings
                .getArray(STORE_DESTINATION_NAMES_ID);
        if (directoryNames == null) {
            directoryNames = new String[0];
        }

        String dest = getDetinationPath();
        if (dest.endsWith(".bos")) {
            dest = new File(dest).getParentFile().getAbsolutePath();
        }
        directoryNames = addToHistory(directoryNames, dest);
        settings.put(STORE_DESTINATION_NAMES_ID, directoryNames);
    }
}
 
Example #8
Source File: EnhancedTableViewer.java    From eclipse-cs with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Saves the sorting state to the dialog settings.
 */
private void saveState() {

  IDialogSettings settings = mSettingsProvider != null ? mSettingsProvider.getTableSettings()
          : null;

  if (settings == null) {
    return;
  }

  settings.put(TAG_COLUMN_INDEX, mSortedColumnIndex);
  settings.put(TAG_SORT_DIRECTION, mSortDirection);

  // store the column widths
  TableColumn[] columns = this.getTable().getColumns();
  for (int i = 0, size = columns.length; i < size; i++) {
    int width = columns[i].getWidth();
    if (width > 0) {
      settings.put(TAG_COLUMN_WIDTH + i, width);
    }
  }

  // store the selection
  settings.put(TAG_CURRENT_SELECTION, this.getTable().getSelectionIndex());
}
 
Example #9
Source File: ExportBarWizardPage.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Hook method for restoring widget values to the values that they held
 * last time this wizard was used to completion.
 */
protected void restoreWidgetValues() {
    final IDialogSettings settings = getDialogSettings();
    if (settings != null) {
        final String[] directoryNames = settings
                .getArray(STORE_DESTINATION_NAMES_ID);
        if (directoryNames == null || directoryNames.length == 0) {
            setDetinationPath(System.getProperty("user.home"));
            return; // ie.- no settings stored
        }

        // destination
        setDetinationPath(directoryNames[0]);
        for (int i = 0; i < directoryNames.length; i++) {
            addDestinationItem(directoryNames[i]);
        }
    }
}
 
Example #10
Source File: SREsPreferencePage.java    From sarl with Apache License 2.0 6 votes vote down vote up
/**
 * Restores the column widths from dialog settings.
 *
 * @param settings the settings to read.
 */
private void restoreColumnWidths(IDialogSettings settings) {
	final int columnCount = this.sreTable.getColumnCount();
	for (int i = 0; i < columnCount; i++) {
		int width = -1;
		try {
			width = settings.getInt(ID + ".columnWidth" + i); //$NON-NLS-1$
		} catch (NumberFormatException exception) {
			//
		}

		if ((width <= 0) || (i == this.sreTable.getColumnCount() - 1)) {
			this.sreTable.getColumn(i).pack();
		} else {
			this.sreTable.getColumn(i).setWidth(width);
		}
	}
}
 
Example #11
Source File: GlobalsTwoPanelElementSelector2.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
@Override
protected void storeDialog(IDialogSettings settings) {
    super.storeDialog(settings);

    XMLMemento memento = XMLMemento.createWriteRoot("workingSet"); //$NON-NLS-1$
    workingSetFilterActionGroup.saveState(memento);
    workingSetFilterActionGroup.dispose();
    StringWriter writer = new StringWriter();
    try {
        memento.save(writer);
        settings.put(WORKINGS_SET_SETTINGS, writer.getBuffer().toString());
    } catch (IOException e) {
        StatusManager.getManager().handle(
                new Status(IStatus.ERROR, AnalysisPlugin.getPluginID(), IStatus.ERROR, "", e)); //$NON-NLS-1$
        // don't do anything. Simply don't store the settings
    }
}
 
Example #12
Source File: AddGetterSetterAction.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
public GetterSetterTreeSelectionDialog(Shell parent, ILabelProvider labelProvider, AddGetterSetterContentProvider contentProvider, CompilationUnitEditor editor, IType type) throws JavaModelException {
	super(parent, labelProvider, contentProvider, editor, type, false);
	fContentProvider= contentProvider;
	fPreviousSelectedFinals= new ArrayList<GetterSetterEntry>();

	// http://bugs.eclipse.org/bugs/show_bug.cgi?id=19253
	IDialogSettings dialogSettings= JavaPlugin.getDefault().getDialogSettings();
	fSettings= dialogSettings.getSection(SETTINGS_SECTION);
	if (fSettings == null) {
		fSettings= dialogSettings.addNewSection(SETTINGS_SECTION);
		fSettings.put(SORT_ORDER, false);
		fSettings.put(ALLOW_SETTERS_FOR_FINALS, false);
	}

	fSortOrder= fSettings.getBoolean(SORT_ORDER);
	fAllowSettersForFinals= fSettings.getBoolean(ALLOW_SETTERS_FOR_FINALS);

	fSettersForFinalFieldsFilter= new SettersForFinalFieldsFilter(contentProvider);
}
 
Example #13
Source File: JarPackageWizardPage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Persists resource specification control setting that are to be restored
 * in the next instance of this page. Subclasses wishing to persist
 * settings for their controls should extend the hook method
 * <code>internalSaveWidgetValues</code>.
 */
@Override
public final void saveWidgetValues() {
	super.saveWidgetValues();
	// update directory names history
	IDialogSettings settings= getDialogSettings();
	if (settings != null) {
		settings.put(STORE_EXPORT_CLASS_FILES, fJarPackage.areClassFilesExported());
		settings.put(STORE_EXPORT_OUTPUT_FOLDERS, fJarPackage.areOutputFoldersExported());
		settings.put(STORE_EXPORT_JAVA_FILES, fJarPackage.areJavaFilesExported());

		// options
		settings.put(STORE_REFACTORINGS, fJarPackage.isRefactoringAware());
		settings.put(STORE_COMPRESS, fJarPackage.isCompressed());
		settings.put(STORE_INCLUDE_DIRECTORY_ENTRIES, fJarPackage.areDirectoryEntriesIncluded());
		settings.put(STORE_OVERWRITE, fJarPackage.allowOverwrite());
	}
	// Allow subclasses to save values
	internalSaveWidgetValues();
}
 
Example #14
Source File: ClasspathContainerSelectionPage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Constructor for ClasspathContainerWizardPage.
 * 
 * @param containerPages the array of container pages
 */
protected ClasspathContainerSelectionPage(ClasspathContainerDescriptor[] containerPages) {
	super("ClasspathContainerWizardPage"); //$NON-NLS-1$
	setTitle(NewWizardMessages.ClasspathContainerSelectionPage_title);
	setDescription(NewWizardMessages.ClasspathContainerSelectionPage_description);
	setImageDescriptor(JavaPluginImages.DESC_WIZBAN_ADD_LIBRARY);

	fContainers= containerPages;

	IDialogSettings settings= JavaPlugin.getDefault().getDialogSettings();
	fDialogSettings= settings.getSection(DIALOGSTORE_SECTION);
	if (fDialogSettings == null) {
		fDialogSettings= settings.addNewSection(DIALOGSTORE_SECTION);
		fDialogSettings.put(DIALOGSTORE_CONTAINER_IDX, 0);
	}
	validatePage();
}
 
Example #15
Source File: SootConfigManagerDialog.java    From JAADAS with GNU General Public License v3.0 6 votes vote down vote up
private void runPressed() {
	super.okPressed();
	if (getSelected() == null) return;
	
	IDialogSettings settings = SootPlugin.getDefault().getDialogSettings();
	String mainClass = settings.get(getSelected()+"_mainClass");
	
	if (getLauncher() instanceof SootConfigProjectLauncher) {
		((SootConfigProjectLauncher)getLauncher()).launch(getSelected(), mainClass);
	}
	else if (getLauncher() instanceof SootConfigJavaProjectLauncher){
		((SootConfigJavaProjectLauncher)getLauncher()).launch(getSelected(), mainClass);
	}
	else if (getLauncher() instanceof SootConfigFileLauncher) {
		((SootConfigFileLauncher)getLauncher()).launch(getSelected(), mainClass);
	}
	else if (getLauncher() instanceof SootConfigFromJavaFileLauncher){
		((SootConfigFromJavaFileLauncher)getLauncher()).launch(getSelected(), mainClass);
	}
	
	
}
 
Example #16
Source File: FilteredItemsSelectionDialog.java    From tlaplus with MIT License 5 votes vote down vote up
/**
 * Restores dialog using persisted settings. The default implementation
 * restores the status of the details line and the selection history.
 *
 * @param settings
 *            settings used to restore dialog
 */
protected void restoreDialog(IDialogSettings settings) {
	boolean toggleStatusLine = true;

	if (settings.get(SHOW_STATUS_LINE) != null) {
		toggleStatusLine = settings.getBoolean(SHOW_STATUS_LINE);
	}

	toggleStatusLineAction.setChecked(toggleStatusLine);

	details.setVisible(toggleStatusLine);

	String setting = settings.get(HISTORY_SETTINGS);
	if (setting != null) {
		try {
			IMemento memento = XMLMemento.createReadRoot(new StringReader(
					setting));
			this.contentProvider.loadHistory(memento);
		} catch (WorkbenchException e) {
			// Simply don't restore the settings
			StatusManager
					.getManager()
					.handle(
							new Status(
									IStatus.ERROR,
									PlatformUI.PLUGIN_ID,
									IStatus.ERROR,
									WorkbenchMessages.FilteredItemsSelectionDialog_restoreError,
									e));
		}
	}
}
 
Example #17
Source File: JarRefactoringDialog.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected Control createDialogArea(final Composite parent) {
	final Composite container= (Composite) super.createDialogArea(parent);
	initializeDialogUnits(container);
	final Composite composite= new Composite(container, SWT.NULL);
	final GridLayout layout= new GridLayout();
	layout.marginHeight= 0;
	layout.marginWidth= 0;
	composite.setLayout(layout);
	composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL));
	final RefactoringHistoryControlConfiguration configuration= new RefactoringHistoryControlConfiguration(null, true, true) {

		@Override
		public final String getWorkspaceCaption() {
			return JarPackagerMessages.JarRefactoringDialog_workspace_caption;
		}
	};
	fHistoryControl= (ISortableRefactoringHistoryControl) RefactoringUI.createSortableRefactoringHistoryControl(composite, configuration);
	fHistoryControl.createControl();
	boolean sortProjects= true;
	final IDialogSettings settings= fSettings;
	if (settings != null)
		sortProjects= settings.getBoolean(SETTING_SORT);
	if (sortProjects)
		fHistoryControl.sortByProjects();
	else
		fHistoryControl.sortByDate();
	GridData data= new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL);
	data.heightHint= convertHeightInCharsToPixels(32);
	data.widthHint= convertWidthInCharsToPixels(72);
	fHistoryControl.getControl().setLayoutData(data);
	fHistoryControl.setInput(fHistory);
	fHistoryControl.setCheckedDescriptors(fData.getRefactoringDescriptors());
	createPlainLabel(composite, JarPackagerMessages.JarPackageWizardPage_options_label);
	createOptionsGroup(composite);
	Dialog.applyDialogFont(parent);
	return composite;
}
 
Example #18
Source File: AbstractNewProjectWizard.java    From typescript.java with MIT License 5 votes vote down vote up
/**
 * Creates a wizard for creating a new project resource in the workspace.
 */
public AbstractNewProjectWizard(String sectionName, String newProjectTitle, String newProjectDescription) {
	this.newProjectTitle = newProjectTitle;
	this.newProjectDescription = newProjectDescription;
	IDialogSettings workbenchSettings = TypeScriptUIPlugin.getDefault().getDialogSettings();
	IDialogSettings section = workbenchSettings.getSection(sectionName);// $NON-NLS-1$
	if (section == null) {
		section = workbenchSettings.addNewSection(sectionName);// $NON-NLS-1$
	}
	setDialogSettings(section);
}
 
Example #19
Source File: PyGeneratorUiPlugin.java    From sarl with Apache License 2.0 5 votes vote down vote up
/**
 * Returns a section in the SARL Eclipse plugin's dialog settings.
 * If the section doesn't exist yet, it is created.
 *
 * @param name the name of the section
 * @return the section of the given name
 */
public IDialogSettings getDialogSettingsSection(String name) {
	final IDialogSettings dialogSettings = getDialogSettings();
	IDialogSettings section = dialogSettings.getSection(name);
	if (section == null) {
		section = dialogSettings.addNewSection(name);
	}
	return section;
}
 
Example #20
Source File: SARLPackageExplorerPart.java    From sarl with Apache License 2.0 5 votes vote down vote up
/** Replies the dialog settings for this view.
 *
 * @return the settings.
 * @throws Error a runtime exception.
 */
protected IDialogSettings getDialogSettings() {
	try {
		return (IDialogSettings) this.reflect.get(this, "fDialogSettings"); //$NON-NLS-1$
	} catch (SecurityException | NoSuchFieldException | IllegalArgumentException | IllegalAccessException e) {
		throw new Error(e);
	}
}
 
Example #21
Source File: ExtractClassWizard.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void dispose() {
	IDialogSettings settings= getRefactoringSettings();
	settings.put(CREATE_GETTER_SETTER, fDescriptor.isCreateGetterSetter());
	settings.put(CREATE_TOP_LEVEL_SETTING, fDescriptor.isCreateTopLevel());
	super.dispose();
}
 
Example #22
Source File: BatchJobsDialog.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
private void loadDialogSettings() {
	IDialogSettings dialogSettings = getDialogSettings();
	deleteEmptyBtn.setSelection(dialogSettings.getBoolean("EMPTY"));
	trimBtn.setSelection(dialogSettings.getBoolean("TRIMENDS"));
	deleteDupliteBtn.setSelection(dialogSettings.getBoolean("DUPLICATE"));
	deleteSameSrcDiffTgtBtn.setSelection(dialogSettings.getBoolean("DIFFRENT"));
	ignoreTagBtn.setEnabled(dialogSettings.getBoolean("IGNORE_TAG_ENALBE"));
	ignoreTagBtn.setSelection(dialogSettings.getBoolean("IGNORE_TAG_SELECT"));
	ignoreCaseBtn.setEnabled(dialogSettings.getBoolean("IGNORE_CASE_ENALBE"));
	ignoreCaseBtn.setSelection(dialogSettings.getBoolean("IGNORE_CASE_SELECT"));
}
 
Example #23
Source File: QuickOutlinePopup.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected IDialogSettings getDialogSettings() {
	String sectionName = "xtext.quickoutline"; //$NON-NLS-1$

	IDialogSettings settings = Activator.getDefault().getDialogSettings().getSection(sectionName);
	if (settings == null) {
		settings = Activator.getDefault().getDialogSettings().addNewSection(sectionName);
	}

	return settings;
}
 
Example #24
Source File: GoSearchPage.java    From goclipse with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Stores it current configuration in the dialog store.
 */
private void writeConfiguration() {
  IDialogSettings s = getDialogSettings();
  s.put(STORE_CASE_SENSITIVE, fIsCaseSensitive);
  s.put(STORE_IS_REG_EX_SEARCH, fIsRegExSearch);

  int historySize = Math.min(fPreviousSearchPatterns.size(), HISTORY_SIZE);
  s.put(STORE_HISTORY_SIZE, historySize);
  for (int i = 0; i < historySize; i++) {
    IDialogSettings histSettings = s.addNewSection(STORE_HISTORY + i);
    SearchPatternData data = fPreviousSearchPatterns.get(i);
    data.store(histSettings);
  }
}
 
Example #25
Source File: ImportTraceWizard.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Default constructor
 */
public ImportTraceWizard() {
    IDialogSettings workbenchSettings = Activator.getDefault().getDialogSettings();
    IDialogSettings section = workbenchSettings.getSection(IMPORT_WIZARD);
    if (section == null) {
        section = workbenchSettings.addNewSection(IMPORT_WIZARD);
    }
    setDialogSettings(section);
}
 
Example #26
Source File: ImportTraceWizardPage.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
private void saveComboValues(Combo combo, IDialogSettings settings, String key) {
    // update names history
    String[] directoryNames = settings.getArray(key);
    if (directoryNames == null) {
        directoryNames = new String[0];
    }

    String items[] = combo.getItems();
    for (int i = 0; i < items.length; i++) {
        directoryNames = addToHistory(directoryNames, items[i]);
    }
    settings.put(key, directoryNames);
}
 
Example #27
Source File: TraceExplorerDataProvider.java    From tlaplus with MIT License 5 votes vote down vote up
/**
   * Creates an error without any replacement of text from the error message reported by TLC.
   * 
   * This overrides the method in TLCModelLaunchDataProvider because that method does a lot
   * of work to search for Strings such as inv_2354234343434 in the error message and replace
   * them with the actual invariant from the MC.tla file. The user should never see anything from
   * the TE file, so this work is unnecessary for the trace explorer.
   * 
   * <br>This is a factory method
   * 
   * @param tlcRegion a region marking the error information in the document
   * @param message the message represented by the region
   * @return the TLC Error representing the error
   */
  protected TLCError createError(TLCRegion tlcRegion, String message)
  {
      // the root of the error trace
final IDialogSettings dialogSettings = Activator.getDefault().getDialogSettings();
      final boolean stateSortOrder = dialogSettings.getBoolean(STATESORTORDER);
final TLCError topError = new TLCError(Order.valueOf(stateSortOrder));

      if (tlcRegion instanceof TLCRegionContainer)
      {
          TLCRegionContainer container = (TLCRegionContainer) tlcRegion;
          // read out the subordinated regions
          ITypedRegion[] regions = container.getSubRegions();

          // currently, there can be at most three regions
          Assert.isTrue(regions.length < 3, "Unexpected error region structure, this is a bug.");

          // iterate over regions
          for (int i = 0; i < regions.length; i++)
          {
              // the region itself is a TLC region, detect the child error
              if (regions[i] instanceof TLCRegion)
              {
                  TLCError cause = createError((TLCRegion) regions[i], message);
                  topError.setCause(cause);
              } else
              {
                  // set error text
                  topError.setMessage(message);
                  // set error code
                  topError.setErrorCode(tlcRegion.getMessageCode());
              }
          }
      }
      return topError;

  }
 
Example #28
Source File: ModulaSearchResultPage.java    From xds-ide with Eclipse Public License 1.0 5 votes vote down vote up
private IDialogSettings getDialogSettings() {
    String sectionName= DLG_ID;

    IDialogSettings settings = XdsPlugin.getDefault().getDialogSettings().getSection(sectionName);
    if (settings == null) {
        settings = XdsPlugin.getDefault().getDialogSettings().addNewSection(sectionName);
    }
    return settings;
}
 
Example #29
Source File: NativeBinaryExportWizard.java    From thym with Eclipse Public License 1.0 5 votes vote down vote up
private void savePageSettings() {
	IDialogSettings workbenchSettings= HybridUI.getDefault().getDialogSettings();
	IDialogSettings section= workbenchSettings.getSection(DIALOG_SETTINGS_KEY);
	if(section == null ){
		section = workbenchSettings.addNewSection(DIALOG_SETTINGS_KEY);
	}
	setDialogSettings(section);
	pageOne.saveWidgetValues();
}
 
Example #30
Source File: JavaSourceViewerConfiguration.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Returns the settings for the given section.
 *
 * @param sectionName the section name
 * @return the settings
 * @since 3.0
 */
private IDialogSettings getSettings(String sectionName) {
	IDialogSettings settings= JavaPlugin.getDefault().getDialogSettings().getSection(sectionName);
	if (settings == null)
		settings= JavaPlugin.getDefault().getDialogSettings().addNewSection(sectionName);

	return settings;
}