use of org.eclipse.jface.preference.IPersistentPreferenceStore in project abstools by abstools.
the class AbsModelManagerImpl method extendedTypechecking.
private void extendedTypechecking() {
if (absNature.getProject() != null) {
IPersistentPreferenceStore projectPreferences = absNature.getProjectPreferenceStore();
IncrementalModelBuilder.flushAll(model);
model.getTypeExt().clearTypeSystemExtensions();
boolean dolocationtypecheck = projectPreferences.getBoolean(LOCATION_TYPECHECK);
if (dolocationtypecheck) {
String defaultlocationtypeprecision = projectPreferences.getString(LOCATION_TYPE_PRECISION);
LocationType defaultLocType = LocationType.createFromName(projectPreferences.getString(DEFAULT_LOCATION_TYPE));
LocationTypeInferrerExtension ltie = new LocationTypeInferrerExtension(model);
ltie.setDefaultType(defaultLocType);
ltie.setLocationTypingPrecision(LocationTypingPrecision.valueOf(defaultlocationtypeprecision));
model.registerTypeSystemExtension(ltie);
}
}
SemanticConditionList typeErrors = model.typeCheck();
updateMarkers(typeErrors);
}
use of org.eclipse.jface.preference.IPersistentPreferenceStore in project xtext-eclipse by eclipse.
the class AbstractToggleActionContributor method toggle.
protected void toggle() {
boolean newState = !isPropertySet();
IPreferenceStore store = preferenceStoreAccess.getWritablePreferenceStore();
store.setValue(getPreferenceKey(), newState);
if (store instanceof IPersistentPreferenceStore) {
try {
((IPersistentPreferenceStore) store).save();
} catch (IOException e) {
// log and ignore
logger.debug(e.getMessage(), e);
}
}
// Prevent sending state change event twice, already called by the propertyChangeListener
if (propertyChangeListener == null)
stateChanged(newState);
}
use of org.eclipse.jface.preference.IPersistentPreferenceStore in project egit by eclipse.
the class CompareTreeView method createActions.
private void createActions() {
IWorkbenchAction reuseCompareEditorAction = new CompareUtils.ReuseCompareEditorAction();
actionsToDispose.add(reuseCompareEditorAction);
getViewSite().getActionBars().getMenuManager().add(reuseCompareEditorAction);
compareModeAction = new BooleanPrefAction((IPersistentPreferenceStore) Activator.getDefault().getPreferenceStore(), UIPreferences.TREE_COMPARE_COMPARE_MODE, UIText.CompareTreeView_CompareModeTooltip) {
@Override
public void apply(boolean value) {
// nothing, just switch the preference
}
};
compareModeAction.setImageDescriptor(UIIcons.ELCL16_COMPARE_VIEW);
compareModeAction.setEnabled(true);
actionsToDispose.add(compareModeAction);
getViewSite().getActionBars().getToolBarManager().add(compareModeAction);
showEqualsAction = new BooleanPrefAction((IPersistentPreferenceStore) Activator.getDefault().getPreferenceStore(), UIPreferences.TREE_COMPARE_SHOW_EQUALS, UIText.CompareTreeView_EqualFilesTooltip) {
@Override
public void apply(boolean value) {
buildTrees(false);
}
};
showEqualsAction.setImageDescriptor(UIIcons.ELCL16_FILTER);
showEqualsAction.setEnabled(false);
actionsToDispose.add(showEqualsAction);
getViewSite().getActionBars().getToolBarManager().add(showEqualsAction);
IAction expandAllAction = new Action(UIText.CompareTreeView_ExpandAllTooltip) {
@Override
public void run() {
tree.expandAll();
}
};
expandAllAction.setImageDescriptor(UIIcons.EXPAND_ALL);
getViewSite().getActionBars().getToolBarManager().add(expandAllAction);
IAction collapseAllAction = new Action(UIText.CompareTreeView_CollapseAllTooltip) {
@Override
public void run() {
tree.collapseAll();
}
};
collapseAllAction.setImageDescriptor(UIIcons.COLLAPSEALL);
getViewSite().getActionBars().getToolBarManager().add(collapseAllAction);
}
use of org.eclipse.jface.preference.IPersistentPreferenceStore in project egit by eclipse.
the class StagingView method updateToolbar.
private void updateToolbar() {
ControlContribution controlContribution = new ControlContribution(// $NON-NLS-1$
"StagingView.searchText") {
@Override
protected Control createControl(Composite parent) {
Composite toolbarComposite = toolkit.createComposite(parent, SWT.NONE);
toolbarComposite.setBackground(null);
GridLayout headLayout = new GridLayout();
headLayout.numColumns = 2;
headLayout.marginHeight = 0;
headLayout.marginWidth = 0;
headLayout.marginTop = 0;
headLayout.marginBottom = 0;
headLayout.marginLeft = 0;
headLayout.marginRight = 0;
toolbarComposite.setLayout(headLayout);
filterText = new Text(toolbarComposite, SWT.SEARCH | SWT.ICON_CANCEL | SWT.ICON_SEARCH);
filterText.setMessage(UIText.StagingView_Find);
GridData data = new GridData(GridData.FILL_HORIZONTAL);
data.widthHint = 150;
filterText.setLayoutData(data);
final Display display = Display.getCurrent();
filterText.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
filterPattern = wildcardToRegex(filterText.getText());
final StagingViewSearchThread searchThread = new StagingViewSearchThread(StagingView.this);
display.timerExec(200, new Runnable() {
@Override
public void run() {
searchThread.start();
}
});
}
});
return toolbarComposite;
}
};
IActionBars actionBars = getViewSite().getActionBars();
IToolBarManager toolbar = actionBars.getToolBarManager();
toolbar.add(controlContribution);
refreshAction = new Action(UIText.StagingView_Refresh, IAction.AS_PUSH_BUTTON) {
@Override
public void run() {
if (cacheEntry != null) {
schedule(cacheEntry.createRefreshResourcesAndIndexDiffJob(), false);
}
}
};
refreshAction.setImageDescriptor(UIIcons.ELCL16_REFRESH);
toolbar.add(refreshAction);
// link with selection
Action linkSelectionAction = new BooleanPrefAction((IPersistentPreferenceStore) getPreferenceStore(), UIPreferences.STAGING_VIEW_SYNC_SELECTION, UIText.StagingView_LinkSelection) {
@Override
public void apply(boolean value) {
reactOnSelection = value;
}
};
linkSelectionAction.setImageDescriptor(UIIcons.ELCL16_SYNCED);
toolbar.add(linkSelectionAction);
toolbar.add(new Separator());
switchRepositoriesAction = new RepositoryToolbarAction(false, () -> realRepository, repo -> {
if (realRepository != repo) {
reload(repo);
}
});
toolbar.add(switchRepositoriesAction);
compareModeAction = new Action(UIText.StagingView_CompareMode, IAction.AS_CHECK_BOX) {
@Override
public void run() {
getPreferenceStore().setValue(UIPreferences.STAGING_VIEW_COMPARE_MODE, isChecked());
}
};
compareModeAction.setImageDescriptor(UIIcons.ELCL16_COMPARE_VIEW);
compareModeAction.setChecked(getPreferenceStore().getBoolean(UIPreferences.STAGING_VIEW_COMPARE_MODE));
toolbar.add(compareModeAction);
toolbar.add(new Separator());
openNewCommitsAction = new Action(UIText.StagingView_OpenNewCommits, IAction.AS_CHECK_BOX) {
@Override
public void run() {
getPreferenceStore().setValue(UIPreferences.STAGING_VIEW_SHOW_NEW_COMMITS, isChecked());
}
};
openNewCommitsAction.setChecked(getPreferenceStore().getBoolean(UIPreferences.STAGING_VIEW_SHOW_NEW_COMMITS));
columnLayoutAction = new Action(UIText.StagingView_ColumnLayout, IAction.AS_CHECK_BOX) {
@Override
public void run() {
getPreferenceStore().setValue(UIPreferences.STAGING_VIEW_COLUMN_LAYOUT, isChecked());
stagingSashForm.setOrientation(isChecked() ? SWT.HORIZONTAL : SWT.VERTICAL);
}
};
columnLayoutAction.setChecked(getPreferenceStore().getBoolean(UIPreferences.STAGING_VIEW_COLUMN_LAYOUT));
fileNameModeAction = new Action(UIText.StagingView_ShowFileNamesFirst, IAction.AS_CHECK_BOX) {
@Override
public void run() {
final boolean enable = isChecked();
getLabelProvider(stagedViewer).setFileNameMode(enable);
getLabelProvider(unstagedViewer).setFileNameMode(enable);
getContentProvider(stagedViewer).setFileNameMode(enable);
getContentProvider(unstagedViewer).setFileNameMode(enable);
StagingEntryComparator comparator = (StagingEntryComparator) unstagedViewer.getComparator();
comparator.setFileNamesFirst(enable);
comparator = (StagingEntryComparator) stagedViewer.getComparator();
comparator.setFileNamesFirst(enable);
getPreferenceStore().setValue(UIPreferences.STAGING_VIEW_FILENAME_MODE, enable);
refreshViewersPreservingExpandedElements();
}
};
fileNameModeAction.setChecked(getPreferenceStore().getBoolean(UIPreferences.STAGING_VIEW_FILENAME_MODE));
IMenuManager dropdownMenu = actionBars.getMenuManager();
MenuManager presentationMenu = new MenuManager(UIText.StagingView_Presentation);
listPresentationAction = new Action(UIText.StagingView_List, IAction.AS_RADIO_BUTTON) {
@Override
public void run() {
if (!isChecked()) {
return;
}
switchToListMode();
refreshViewers();
}
};
listPresentationAction.setImageDescriptor(UIIcons.FLAT);
presentationMenu.add(listPresentationAction);
treePresentationAction = new Action(UIText.StagingView_Tree, IAction.AS_RADIO_BUTTON) {
@Override
public void run() {
if (!isChecked()) {
return;
}
presentation = Presentation.TREE;
setPresentation(presentation, false);
listPresentationAction.setChecked(false);
compactTreePresentationAction.setChecked(false);
setExpandCollapseActionsVisible(false, isExpandAllowed(false), true);
setExpandCollapseActionsVisible(true, isExpandAllowed(true), true);
refreshViewers();
}
};
treePresentationAction.setImageDescriptor(UIIcons.HIERARCHY);
presentationMenu.add(treePresentationAction);
compactTreePresentationAction = new Action(UIText.StagingView_CompactTree, IAction.AS_RADIO_BUTTON) {
@Override
public void run() {
if (!isChecked()) {
return;
}
switchToCompactModeInternal(false);
refreshViewers();
}
};
compactTreePresentationAction.setImageDescriptor(UIIcons.COMPACT);
presentationMenu.add(compactTreePresentationAction);
presentation = readPresentation(UIPreferences.STAGING_VIEW_PRESENTATION, Presentation.LIST);
switch(presentation) {
case LIST:
listPresentationAction.setChecked(true);
setExpandCollapseActionsVisible(false, false, false);
setExpandCollapseActionsVisible(true, false, false);
break;
case TREE:
treePresentationAction.setChecked(true);
break;
case COMPACT_TREE:
compactTreePresentationAction.setChecked(true);
break;
default:
break;
}
dropdownMenu.add(presentationMenu);
dropdownMenu.add(new Separator());
dropdownMenu.add(openNewCommitsAction);
dropdownMenu.add(columnLayoutAction);
dropdownMenu.add(fileNameModeAction);
dropdownMenu.add(compareModeAction);
actionBars.setGlobalActionHandler(ActionFactory.DELETE.getId(), new GlobalDeleteActionHandler());
// For the normal resource undo/redo actions to be active, so that files
// deleted via the "Delete" action in the staging view can be restored.
IUndoContext workspaceContext = AdapterUtils.adapt(ResourcesPlugin.getWorkspace(), IUndoContext.class);
undoRedoActionGroup = new UndoRedoActionGroup(getViewSite(), workspaceContext, true);
undoRedoActionGroup.fillActionBars(actionBars);
actionBars.updateActionBars();
}
Aggregations