use of org.eclipse.jface.preference.IPreferenceNode in project tdi-studio-se by Talend.
the class ProjectSettingsPreferenceDialog method openPage.
@Override
public boolean openPage(String nodeId, Object data) {
if (this instanceof IWorkbenchPreferenceContainer) {
((IWorkbenchPreferenceContainer) this).openPage(nodeId, data);
} else {
// impl by self
final IPreferenceNode node = findNodeMatching(nodeId);
if (node != null) {
getTreeViewer().setSelection(new StructuredSelection(node));
showPage(node);
}
IPreferencePage page = getCurrentPage();
if (page instanceof PreferencePage) {
((PreferencePage) page).applyData(data);
}
return true;
}
return false;
}
use of org.eclipse.jface.preference.IPreferenceNode in project tdi-studio-se by Talend.
the class ProjectSettingsPreferenceDialog method addChildrenPreferenceNodes.
@Override
public boolean addChildrenPreferenceNodes(String parentId, List<IPreferenceNode> childrenNodes) {
IPreferenceNode findNodeMatching = findNodeMatching(parentId);
if (findNodeMatching != null && childrenNodes != null) {
IPreferenceNode[] subNodes = findNodeMatching.getSubNodes();
// remove old one to make sure the add nodes is front.
if (subNodes != null) {
for (IPreferenceNode n : subNodes) {
findNodeMatching.remove(n);
}
}
// add new nodes.
for (IPreferenceNode n : childrenNodes) {
findNodeMatching.add(n);
}
// add back the original nodes.
for (IPreferenceNode n : subNodes) {
findNodeMatching.add(n);
}
this.getTreeViewer().refresh();
return true;
}
return false;
}
use of org.eclipse.jface.preference.IPreferenceNode in project translationstudio8 by heartsome.
the class ProjectSettingDialog method addListeners.
protected void addListeners(final TreeViewer viewer) {
viewer.addPostSelectionChangedListener(new ISelectionChangedListener() {
private void handleError() {
try {
// remove the listener temporarily so that the events caused
// by the error handling dont further cause error handling
// to occur.
viewer.removePostSelectionChangedListener(this);
// select Current PageAgain;
if (lastSuccessfulNode == null) {
return;
}
getTreeViewer().setSelection(new StructuredSelection(lastSuccessfulNode));
getCurrentPage().setVisible(true);
// clear Selected Node
setSelectedNodePreference(null);
} finally {
viewer.addPostSelectionChangedListener(this);
}
}
public void selectionChanged(SelectionChangedEvent event) {
final Object selection = getSingleSelection(event.getSelection());
if (selection instanceof IPreferenceNode) {
BusyIndicator.showWhile(getShell().getDisplay(), new Runnable() {
public void run() {
if (!isCurrentPageValid()) {
handleError();
} else if (!showPage((IPreferenceNode) selection)) {
// Page flipping wasn't successful
handleError();
} else {
// Everything went well
lastSuccessfulNode = (IPreferenceNode) selection;
}
}
});
}
}
});
((Tree) viewer.getControl()).addSelectionListener(new SelectionAdapter() {
public void widgetDefaultSelected(final SelectionEvent event) {
ISelection selection = viewer.getSelection();
if (selection.isEmpty()) {
return;
}
IPreferenceNode singleSelection = getSingleSelection(selection);
boolean expanded = viewer.getExpandedState(singleSelection);
viewer.setExpandedState(singleSelection, !expanded);
}
});
// Register help listener on the tree to use context sensitive help
viewer.getControl().addHelpListener(new HelpListener() {
public void helpRequested(HelpEvent event) {
if (getCurrentPage() == null) {
// no current page? open dialog's help
openDialogHelp();
return;
}
// A) A typical path: the current page has registered its own help link
// via WorkbenchHelpSystem#setHelp(). When just call it and let
// it handle the help request.
Control pageControl = getCurrentPage().getControl();
if (pageControl != null && pageControl.isListening(SWT.Help)) {
getCurrentPage().performHelp();
return;
}
// B) Less typical path: no standard listener has been created for the page.
// In this case we may or may not have an override of page's #performHelp().
// 1) Try to get default help opened for the dialog;
openDialogHelp();
// 2) Next call currentPage's #performHelp(). If it was overridden, it might switch help
// to something else.
getCurrentPage().performHelp();
}
private void openDialogHelp() {
if (getPageContainer() == null)
return;
for (Control currentControl = getPageContainer(); currentControl != null; currentControl = currentControl.getParent()) {
if (currentControl.isListening(SWT.Help)) {
currentControl.notifyListeners(SWT.Help, new Event());
break;
}
}
}
});
}
use of org.eclipse.jface.preference.IPreferenceNode in project translationstudio8 by heartsome.
the class ProjectSettingDialog method selectSavedItem.
/**
* Selects the saved item in the tree of preference pages. If it cannot do this it saves the first one.
*/
protected void selectSavedItem() {
IPreferenceNode node = findNodeMatching(getSelectedNodePreference());
if (node == null) {
IPreferenceNode[] nodes = preferenceManager.getRootSubNodes();
ViewerComparator comparator = getTreeViewer().getComparator();
if (comparator != null) {
comparator.sort(null, nodes);
}
for (int i = 0; i < nodes.length; i++) {
IPreferenceNode selectedNode = nodes[i];
if (selectedNode != null) {
node = selectedNode;
break;
}
}
}
if (node != null) {
getTreeViewer().setSelection(new StructuredSelection(node), true);
// Keep focus in tree. See bugs 2692, 2621, and 6775.
getTreeViewer().getControl().setFocus();
boolean expanded = getTreeViewer().getExpandedState(node);
getTreeViewer().setExpandedState(node, !expanded);
}
}
use of org.eclipse.jface.preference.IPreferenceNode in project cubrid-manager by CUBRID.
the class ApplicationWorkbenchWindowAdvisor method removePlatformDependencyActions.
private void removePlatformDependencyActions() {
// remove some menu items
IMenuManager mm = getWindowConfigurer().getActionBarConfigurer().getMenuManager();
for (IContributionItem item : mm.getItems()) {
if (item == null) {
continue;
}
MenuManager sm = (MenuManager) item;
for (IContributionItem sitem : sm.getItems()) {
if (sitem == null || sitem.getId() == null) {
continue;
}
if (sitem.getId().equals("org.eclipse.ui.actions.showKeyAssistHandler") || sitem.getId().equals("com.cubrid.common.update.p2.menu.install") || sitem.getId().equals("converstLineDelimitersTo") || sitem.getId().equals("save.ext") || sitem.getId().equals("org.eclipse.ui.openLocalFile") || sitem.getId().equals("new.ext")) {
sm.remove(sitem.getId());
sm.update(true);
mm.update(true);
}
}
}
// remove some tool bar items
ICoolBarManager cm = getWindowConfigurer().getActionBarConfigurer().getCoolBarManager();
for (IContributionItem item : cm.getItems()) {
if (item == null || item.getId() == null) {
continue;
}
if (item.getId().equals("org.eclipse.ui.edit.text.actionSet.annotationNavigation") || item.getId().equals("org.eclipse.ui.edit.text.actionSet.navigation")) {
cm.remove(item.getId());
cm.update(true);
}
}
// remove some preference items
PreferenceManager pm = getWindowConfigurer().getWindow().getWorkbench().getPreferenceManager();
for (IPreferenceNode item : pm.getRootSubNodes()) {
if (item.getId().equals("org.eclipse.help.ui.browsersPreferencePage") || item.getId().equals("org.eclipse.ui.preferencePages.Workbench")) {
pm.remove(item.getId());
}
}
}
Aggregations