List of usage examples for org.eclipse.jface.action IToolBarManager getItems
IContributionItem[] getItems();
From source file:org.eclipse.ui.tests.api.MockViewPart.java
License:Open Source License
public void createPartControl(Composite parent) { super.createPartControl(parent); Button addAction = new Button(parent, SWT.PUSH); addAction.setText("Add Action to Tool Bar"); addAction.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { IActionBars bars = getViewSite().getActionBars(); bars.getToolBarManager().add(new DummyAction()); bars.updateActionBars();//from w w w . ja va 2s. c o m } }); Button removeAction = new Button(parent, SWT.PUSH); removeAction.setText("Remove Action from Tool Bar"); removeAction.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { IActionBars bars = getViewSite().getActionBars(); IToolBarManager tbm = bars.getToolBarManager(); IContributionItem[] items = tbm.getItems(); if (items.length > 0) { IContributionItem item = items[items.length - 1]; if (item instanceof ActionContributionItem) { if (((ActionContributionItem) item).getAction() instanceof DummyAction) { tbm.remove(item); bars.updateActionBars(); } } } } }); }
From source file:org.eclipse.ui.tests.internal.EditorActionBarsTest.java
License:Open Source License
/** * Confirms that a ToolBar is not null when you're looking a manager that * is a CoolItemToolBarManager and it has non-separator/non-invisible * contributions.//from w w w . j a va2s .co m * This is a consequence of the changes made to * CoolItemToolBarManager.update() that hides the a bar if it does not * contain anything as per the above mentioned criteria. Under this * circumstance, the underlying ToolBar is not created. * * @param tb the ToolBar to check * @param actionText the action text * @param manager the IToolBarManager containing items * @since 3.0 */ private void verifyNullToolbar(ToolBar tb, String actionText, IToolBarManager manager) { if (tb == null) { // toolbar should only be null if the given manager is // a CoolBarManager and it contains only separators or invisible // objects. IContributionItem[] items = manager.getItems(); for (int i = 0; i < items.length; i++) { if (!(items[i] instanceof Separator) && items[i].isVisible()) { fail("No toolbar for a visible action text \"" + actionText + "\""); } } } }
From source file:org.eclipse.ui.tests.propertysheet.AbstractPropertySheetTest.java
License:Open Source License
protected IAction getPinPropertySheetAction(PropertySheet propertySheet) { IActionBars actionBars = propertySheet.getViewSite().getActionBars(); IToolBarManager toolBarManager = actionBars.getToolBarManager(); IContributionItem[] items = toolBarManager.getItems(); for (int i = 0; i < items.length; i++) { IContributionItem contributionItem = items[i]; if (contributionItem.getId() != null && contributionItem.getId().startsWith(PIN_PROPERTY_SHEET_ACTION_ID_PREFIX)) { IAction action = ((ActionContributionItem) contributionItem).getAction(); return action; }/*from w w w .ja va 2 s. c om*/ } return null; }
From source file:org.fusesource.ide.jvmmonitor.internal.ui.editors.CpuDumpEditor.java
License:Open Source License
/** * Contributes to action bars./*from ww w .ja va2s . c o m*/ */ private void contributeToActionBars() { IActionBars actionBars = getEditorSite().getActionBars(); IToolBarManager manager = actionBars.getToolBarManager(); collapseAllAction = new CollapseAllAction(); // check if CollapseAllAction has been already added boolean exist = false; for (IContributionItem contributionItem : manager.getItems()) { if (contributionItem.getId().equals(collapseAllAction.getId())) { exist = true; break; } } if (!exist) { manager.add(collapseAllAction); } actionBars.setGlobalActionHandler(JdtActionConstants.OPEN, new OpenDeclarationAction()); actionBars.setGlobalActionHandler(ActionFactory.FIND.getId(), new FindAction()); actionBars.setGlobalActionHandler(ActionFactory.COPY.getId(), new CopyAction()); }
From source file:org.hibernate.eclipse.hqleditor.HQLEditorTest.java
License:Open Source License
public void testSingleLineCommentsCutOff() throws PartInitException { String query = "from pack.Article a\n" + //$NON-NLS-1$ "where a.articleid in (:a, :b) --or a.articleid = :c"; //$NON-NLS-1$ IEditorPart editorPart = HibernateConsolePlugin.getDefault() .openScratchHQLEditor(consoleConfiguration.getName(), query); assertTrue("Opened editor is not HQLEditor", editorPart instanceof HQLEditor); //$NON-NLS-1$ HQLEditor editor = (HQLEditor) editorPart; assertEquals(editor.getEditorText(), query); assertFalse("Comments were not cut off", editor.getQueryString().contains("--")); //$NON-NLS-1$ //$NON-NLS-2$ QueryInputModel model = editor.getQueryInputModel(); assertTrue(model.getParameterCount() == 0); IViewPart view = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage() .showView("org.hibernate.eclipse.console.views.QueryParametersView"); //$NON-NLS-1$ assertNotNull("View was not opened", view); //$NON-NLS-1$ assertTrue("Opened view is not QueryParametersView", view instanceof QueryParametersView); //$NON-NLS-1$ QueryParametersView paramView = (QueryParametersView) view; IPage ipage = paramView.getCurrentPage(); assertNotNull("Current Page is NULL", ipage); //$NON-NLS-1$ assertTrue("Page is not Query Parameters Page", ipage instanceof QueryParametersPage); //$NON-NLS-1$ QueryParametersPage page = (QueryParametersPage) ipage; IToolBarManager manager = page.getSite().getActionBars().getToolBarManager(); IContributionItem[] items = manager.getItems(); ActionContributionItem addParamItem = null; for (int i = 0; i < items.length; i++) { ActionContributionItem item = (ActionContributionItem) items[i]; if (item.getAction().getClass().getName().endsWith("NewRowAction")) { //$NON-NLS-1$ addParamItem = item;/*from w ww . j a va2 s . c om*/ break; } } assertNotNull(HibernateConsoleMessages.QueryParametersPage_add_query_parameter_tooltip + " item not found", //$NON-NLS-1$ addParamItem); addParamItem.getAction().run();//add query parameters automatically assertTrue(model.getParameterCount() == 2);//a and b }
From source file:org.jboss.tools.jsf.ui.action.JSFMultiPageContributor.java
License:Open Source License
public void setActivePage(IEditorPart part) { cleanStatusLine();//from w ww . j a v a 2s . c o m fActiveEditorPart = part; IActionBars actionBars = getActionBars(); if (actionBars != null) { ActionRegistry registry = null; if (fActiveEditorPart instanceof FacesConfigGuiEditor) registry = (ActionRegistry) part.getAdapter(ActionRegistry.class); Iterator<String> globalActionKeys = registrySupport.getGlobalActionKeys(); while (globalActionKeys.hasNext()) { String id = (String) globalActionKeys.next(); actionBars.setGlobalActionHandler(id, (registry == null ? null : registry.getAction(id))); } IToolBarManager tbm = actionBars.getToolBarManager(); IContributionItem[] items = tbm.getItems(); if (items != null) { for (int i = 0; i < items.length; i++) { String id = items[i].getId(); if (id == null) continue; //Separator actionBars.setGlobalActionHandler(id, (registry == null ? null : registry.getAction(id))); } } ITextEditor editor = (part instanceof ITextEditor) ? (ITextEditor) part : null; if (editor != null) { actionBars.setGlobalActionHandler(ActionFactory.DELETE.getId(), (registry != null) ? registry.getAction(ActionFactory.DELETE.getId()) : (editor != null) ? getAction(editor, ActionFactory.DELETE.getId()) : null); actionBars.setGlobalActionHandler(ActionFactory.UNDO.getId(), getAction(editor, ActionFactory.UNDO.getId())); actionBars.setGlobalActionHandler(ActionFactory.REDO.getId(), getAction(editor, ActionFactory.REDO.getId())); actionBars.setGlobalActionHandler(ActionFactory.CUT.getId(), (registry != null) ? registry.getAction(ActionFactory.CUT.getId()) : (editor != null) ? getAction(editor, ActionFactory.CUT.getId()) : null); actionBars.setGlobalActionHandler(ActionFactory.COPY.getId(), (registry != null) ? registry.getAction(ActionFactory.COPY.getId()) : (editor != null) ? getAction(editor, ActionFactory.COPY.getId()) : null); actionBars.setGlobalActionHandler(ActionFactory.PASTE.getId(), (registry != null) ? registry.getAction(ActionFactory.PASTE.getId()) : (editor != null) ? getAction(editor, ActionFactory.PASTE.getId()) : null); actionBars.setGlobalActionHandler(ActionFactory.SELECT_ALL.getId(), getAction(editor, ActionFactory.SELECT_ALL.getId())); actionBars.setGlobalActionHandler(ActionFactory.FIND.getId(), getAction(editor, ActionFactory.FIND.getId())); actionBars.setGlobalActionHandler(IDEActionFactory.BOOKMARK.getId(), getAction(editor, IDEActionFactory.BOOKMARK.getId())); actionBars.setGlobalActionHandler(IDEActionFactory.ADD_TASK.getId(), getAction(editor, IDEActionFactory.ADD_TASK.getId())); actionBars.setGlobalActionHandler(ActionFactory.PRINT.getId(), (registry != null) ? registry.getAction("Print_Diagram") //$NON-NLS-1$ : (editor != null) ? getAction(editor, ActionFactory.PRINT.getId()) : null); actionBars.setGlobalActionHandler(ActionFactory.REVERT.getId(), getAction(editor, ActionFactory.REVERT.getId())); actionBars.setGlobalActionHandler(ActionFactory.SAVE.getId(), getAction(editor, ActionFactory.SAVE.getId())); actionBars.setGlobalActionHandler( StructuredTextEditorActionConstants.ACTION_NAME_CONTENTASSIST_PROPOSALS, getAction(editor, StructuredTextEditorActionConstants.ACTION_NAME_CONTENTASSIST_PROPOSALS)); } else { actionBars.setGlobalActionHandler(ActionFactory.UNDO.getId(), null); actionBars.setGlobalActionHandler(ActionFactory.REDO.getId(), null); } // re-register action on key binding service IEditorPart localPart = (part != null) ? part : mainPart; IHandlerService handler = (IHandlerService) localPart.getEditorSite().getService(IHandlerService.class); if (registry != null) { registerKeyBindings(handler, ACTIONS_1, registry); } else if (editor != null) { // editor registerKeyBindings(handler, ACTIONS_2, editor); } else { //fakeTextEditor registerKeyBindings(handler, ACTIONS_1, fakeTextEditor); } cleanActionBarStatus(); actionBars.updateActionBars(); } ITextEditor textEditor = getTextEditor(part); if (fToggleOccurencesMarkUp != null) { fToggleOccurencesMarkUp.setEditor(textEditor); fToggleOccurencesMarkUp.update(); } fGoToMatchingTagAction.setEditor(textEditor); if (textEditor != null) { textEditor.setAction(GO_TO_MATCHING_TAG_ID, fGoToMatchingTagAction); } updateStatus(); }
From source file:org.jboss.tools.jst.web.tiles.ui.editor.action.TilesMultiPageContributor.java
License:Open Source License
public void setActivePage(IEditorPart part) { if (fActiveEditorPart == part) return;/*from www .j a v a2 s. c om*/ cleanStatusLine(); fActiveEditorPart = part; IActionBars actionBars = getActionBars(); if (actionBars != null) { ActionRegistry registry = null; if (fActiveEditorPart instanceof TilesGuiEditor) registry = (ActionRegistry) part.getAdapter(ActionRegistry.class); Iterator globalActionKeys = registrySupport.getGlobalActionKeys(); while (globalActionKeys.hasNext()) { String id = (String) globalActionKeys.next(); actionBars.setGlobalActionHandler(id, (registry == null ? null : registry.getAction(id))); } IToolBarManager tbm = actionBars.getToolBarManager(); IContributionItem[] items = tbm.getItems(); if (items != null) { for (int i = 0; i < items.length; i++) { String id = items[i].getId(); if (id == null) continue; //Separator actionBars.setGlobalActionHandler(id, (registry == null ? null : registry.getAction(id))); } } ITextEditor editor = (part instanceof ITextEditor) ? (ITextEditor) part : null; if (editor != null) { actionBars.setGlobalActionHandler(ActionFactory.DELETE.getId(), (registry != null) ? registry.getAction(ITextEditorActionConstants.DELETE) : (editor != null) ? getAction(editor, ITextEditorActionConstants.DELETE) : null); actionBars.setGlobalActionHandler(ActionFactory.UNDO.getId(), getAction(editor, ITextEditorActionConstants.UNDO)); actionBars.setGlobalActionHandler(ActionFactory.REDO.getId(), getAction(editor, ITextEditorActionConstants.REDO)); actionBars.setGlobalActionHandler(ActionFactory.CUT.getId(), (registry != null) ? registry.getAction(ITextEditorActionConstants.CUT) : (editor != null) ? getAction(editor, ITextEditorActionConstants.CUT) : null); actionBars.setGlobalActionHandler(ActionFactory.COPY.getId(), (registry != null) ? registry.getAction(ITextEditorActionConstants.COPY) : (editor != null) ? getAction(editor, ITextEditorActionConstants.COPY) : null); actionBars.setGlobalActionHandler(ActionFactory.PASTE.getId(), (registry != null) ? registry.getAction(ITextEditorActionConstants.PASTE) : (editor != null) ? getAction(editor, ITextEditorActionConstants.PASTE) : null); actionBars.setGlobalActionHandler(ActionFactory.SELECT_ALL.getId(), getAction(editor, ITextEditorActionConstants.SELECT_ALL)); actionBars.setGlobalActionHandler(ActionFactory.FIND.getId(), getAction(editor, ITextEditorActionConstants.FIND)); actionBars.setGlobalActionHandler(IDEActionFactory.BOOKMARK.getId(), getAction(editor, IDEActionFactory.BOOKMARK.getId())); actionBars.setGlobalActionHandler(IDEActionFactory.ADD_TASK.getId(), getAction(editor, IDEActionFactory.ADD_TASK.getId())); actionBars.setGlobalActionHandler(ActionFactory.PRINT.getId(), (registry != null) ? registry.getAction("Print_Diagram") //$NON-NLS-1$ : (editor != null) ? getAction(editor, ActionFactory.PRINT.getId()) : null); actionBars.setGlobalActionHandler(ActionFactory.REVERT.getId(), getAction(editor, ITextEditorActionConstants.REVERT)); actionBars.setGlobalActionHandler(ActionFactory.SAVE.getId(), getAction(editor, ITextEditorActionConstants.SAVE)); } else { actionBars.setGlobalActionHandler(ActionFactory.UNDO.getId(), null); actionBars.setGlobalActionHandler(ActionFactory.REDO.getId(), null); } // re-register action on key binding service IEditorPart localPart = (part != null) ? part : mainPart; IHandlerService handler = (IHandlerService) localPart.getEditorSite().getService(IHandlerService.class); if (registry != null) { registerKeyBindings(handler, ACTIONS_1, registry); } else if (editor != null) { // editor registerKeyBindings(handler, ACTIONS_2, editor); } else { //fakeTextEditor // registerKeyBindings(handler, ACTIONS_1, fakeTextEditor); } cleanActionBarStatus(); actionBars.updateActionBars(); } updateStatus(); }
From source file:org.jboss.tools.seam.ui.pages.editor.PagesMultiPageContributor.java
License:Open Source License
public void setActivePage(IEditorPart part) { cleanStatusLine();/*from ww w . ja v a 2s . c om*/ fActiveEditorPart = part; IActionBars actionBars = getActionBars(); if (actionBars != null) { ActionRegistry registry = null; if (fActiveEditorPart instanceof SeamPagesGuiEditor) registry = (ActionRegistry) part.getAdapter(ActionRegistry.class); Iterator<String> globalActionKeys = registrySupport.getGlobalActionKeys(); while (globalActionKeys.hasNext()) { String id = (String) globalActionKeys.next(); actionBars.setGlobalActionHandler(id, (registry == null ? null : registry.getAction(id))); } IToolBarManager tbm = actionBars.getToolBarManager(); IContributionItem[] items = tbm.getItems(); if (items != null) { for (int i = 0; i < items.length; i++) { String id = items[i].getId(); if (id == null) continue; //Separator actionBars.setGlobalActionHandler(id, (registry == null ? null : registry.getAction(id))); } } ITextEditor editor = (part instanceof ITextEditor) ? (ITextEditor) part : null; if (editor != null) { actionBars.setGlobalActionHandler(ActionFactory.DELETE.getId(), (registry != null) ? registry.getAction(ActionFactory.DELETE.getId()) : (editor != null) ? getAction(editor, ActionFactory.DELETE.getId()) : null); actionBars.setGlobalActionHandler(ActionFactory.UNDO.getId(), getAction(editor, ActionFactory.UNDO.getId())); actionBars.setGlobalActionHandler(ActionFactory.REDO.getId(), getAction(editor, ActionFactory.REDO.getId())); actionBars.setGlobalActionHandler(ActionFactory.CUT.getId(), (registry != null) ? registry.getAction(ActionFactory.CUT.getId()) : (editor != null) ? getAction(editor, ActionFactory.CUT.getId()) : null); actionBars.setGlobalActionHandler(ActionFactory.COPY.getId(), (registry != null) ? registry.getAction(ActionFactory.COPY.getId()) : (editor != null) ? getAction(editor, ActionFactory.COPY.getId()) : null); actionBars.setGlobalActionHandler(ActionFactory.PASTE.getId(), (registry != null) ? registry.getAction(ActionFactory.PASTE.getId()) : (editor != null) ? getAction(editor, ActionFactory.PASTE.getId()) : null); actionBars.setGlobalActionHandler(ActionFactory.SELECT_ALL.getId(), getAction(editor, ActionFactory.SELECT_ALL.getId())); actionBars.setGlobalActionHandler(ActionFactory.FIND.getId(), getAction(editor, ActionFactory.FIND.getId())); actionBars.setGlobalActionHandler(IDEActionFactory.BOOKMARK.getId(), getAction(editor, IDEActionFactory.BOOKMARK.getId())); actionBars.setGlobalActionHandler(IDEActionFactory.ADD_TASK.getId(), getAction(editor, IDEActionFactory.ADD_TASK.getId())); actionBars.setGlobalActionHandler(ActionFactory.PRINT.getId(), (registry != null) ? registry.getAction("Print_Diagram") : (editor != null) ? getAction(editor, ActionFactory.PRINT.getId()) : null); actionBars.setGlobalActionHandler(ActionFactory.REVERT.getId(), getAction(editor, ActionFactory.REVERT.getId())); actionBars.setGlobalActionHandler(ActionFactory.SAVE.getId(), getAction(editor, ActionFactory.SAVE.getId())); actionBars.setGlobalActionHandler( StructuredTextEditorActionConstants.ACTION_NAME_CONTENTASSIST_PROPOSALS, getAction(editor, StructuredTextEditorActionConstants.ACTION_NAME_CONTENTASSIST_PROPOSALS)); } else { actionBars.setGlobalActionHandler(ActionFactory.UNDO.getId(), null); actionBars.setGlobalActionHandler(ActionFactory.REDO.getId(), null); } // re-register action on key binding service IEditorPart localPart = (part != null) ? part : mainPart; IHandlerService handler = (IHandlerService) localPart.getEditorSite().getService(IHandlerService.class); if (registry != null) { registerKeyBindings(handler, ACTIONS_1, registry); } else if (editor != null) { // editor registerKeyBindings(handler, ACTIONS_2, editor); } else { //fakeTextEditor registerKeyBindings(handler, ACTIONS_1, fakeTextEditor); } cleanActionBarStatus(); actionBars.updateActionBars(); } ITextEditor textEditor = getTextEditor(part); if (fToggleOccurencesMarkUp != null) { fToggleOccurencesMarkUp.setEditor(textEditor); fToggleOccurencesMarkUp.update(); } fGoToMatchingTagAction.setEditor(textEditor); if (textEditor != null) { textEditor.setAction(GO_TO_MATCHING_TAG_ID, fGoToMatchingTagAction); } updateStatus(); }
From source file:org.jboss.tools.struts.ui.action.StrutsMultiPageContributor.java
License:Open Source License
public void setActivePage(IEditorPart part) { /// if (fActiveEditorPart == part) return; cleanStatusLine();// ww w . j a v a 2 s . c om fActiveEditorPart = part; IActionBars actionBars = getActionBars(); if (actionBars != null) { ActionRegistry registry = null; if (fActiveEditorPart instanceof StrutsConfigGuiEditor) registry = (ActionRegistry) part.getAdapter(ActionRegistry.class); Iterator globalActionKeys = registrySupport.getGlobalActionKeys(); while (globalActionKeys.hasNext()) { String id = (String) globalActionKeys.next(); actionBars.setGlobalActionHandler(id, (registry == null ? null : registry.getAction(id))); } IToolBarManager tbm = actionBars.getToolBarManager(); IContributionItem[] items = tbm.getItems(); if (items != null) { for (int i = 0; i < items.length; i++) { String id = items[i].getId(); if (id == null) continue; //Separator actionBars.setGlobalActionHandler(id, (registry == null ? null : registry.getAction(id))); } } ITextEditor editor = (part instanceof ITextEditor) ? (ITextEditor) part : null; if (editor != null) { actionBars.setGlobalActionHandler(ActionFactory.DELETE.getId(), (registry != null) ? registry.getAction(ITextEditorActionConstants.DELETE) : (editor != null) ? getAction(editor, ITextEditorActionConstants.DELETE) : null); actionBars.setGlobalActionHandler(ActionFactory.UNDO.getId(), getAction(editor, ITextEditorActionConstants.UNDO)); actionBars.setGlobalActionHandler(ActionFactory.REDO.getId(), getAction(editor, ITextEditorActionConstants.REDO)); actionBars.setGlobalActionHandler(ActionFactory.CUT.getId(), (registry != null) ? registry.getAction(ITextEditorActionConstants.CUT) : (editor != null) ? getAction(editor, ITextEditorActionConstants.CUT) : null); actionBars.setGlobalActionHandler(ActionFactory.COPY.getId(), (registry != null) ? registry.getAction(ITextEditorActionConstants.COPY) : (editor != null) ? getAction(editor, ITextEditorActionConstants.COPY) : null); actionBars.setGlobalActionHandler(ActionFactory.PASTE.getId(), (registry != null) ? registry.getAction(ITextEditorActionConstants.PASTE) : (editor != null) ? getAction(editor, ITextEditorActionConstants.PASTE) : null); actionBars.setGlobalActionHandler(ActionFactory.SELECT_ALL.getId(), getAction(editor, ITextEditorActionConstants.SELECT_ALL)); actionBars.setGlobalActionHandler(ActionFactory.FIND.getId(), getAction(editor, ITextEditorActionConstants.FIND)); actionBars.setGlobalActionHandler(IDEActionFactory.BOOKMARK.getId(), getAction(editor, IDEActionFactory.BOOKMARK.getId())); actionBars.setGlobalActionHandler(IDEActionFactory.ADD_TASK.getId(), getAction(editor, IDEActionFactory.ADD_TASK.getId())); actionBars.setGlobalActionHandler(ActionFactory.PRINT.getId(), (registry != null) ? registry.getAction("Print_Diagram") : (editor != null) ? getAction(editor, ActionFactory.PRINT.getId()) : null); actionBars.setGlobalActionHandler(ActionFactory.REVERT.getId(), getAction(editor, ITextEditorActionConstants.REVERT)); actionBars.setGlobalActionHandler(ActionFactory.SAVE.getId(), getAction(editor, ITextEditorActionConstants.SAVE)); actionBars.setGlobalActionHandler( StructuredTextEditorActionConstants.ACTION_NAME_CONTENTASSIST_PROPOSALS, getAction(editor, StructuredTextEditorActionConstants.ACTION_NAME_CONTENTASSIST_PROPOSALS)); } else { actionBars.setGlobalActionHandler(ActionFactory.UNDO.getId(), null); actionBars.setGlobalActionHandler(ActionFactory.REDO.getId(), null); } // re-register action on key binding service IEditorPart localPart = (part != null) ? part : mainPart; IHandlerService handler = (IHandlerService) localPart.getEditorSite().getService(IHandlerService.class); if (registry != null) { registerKeyBindings(handler, ACTIONS_1, registry); } else if (editor != null) { // editor registerKeyBindings(handler, ACTIONS_2, editor); } else { //fakeTextEditor registerKeyBindings(handler, ACTIONS_1, fakeTextEditor); } cleanActionBarStatus(); actionBars.updateActionBars(); } updateStatus(); }
From source file:org.locationtech.udig.style.sld.SLDConfigurator.java
License:Open Source License
protected void refresh() { Layer layer = getLayer();/*from w ww . j av a 2 s . co m*/ if (!canStyle(layer)) { throw new IllegalStateException("Hey I can't style " + layer); //$NON-NLS-1$ } // pull the sld style off the blackboard, and initialize the cm Style style = (Style) getStyleBlackboard().get(SLDContent.ID); // if no style information, create default if (style == null) { style = SLDContent.createDefaultStyle(); getStyleBlackboard().put(SLDContent.ID, style); } sldContentManager.init(SLDContent.getStyleBuilder(), style); // pull the feature type name out of the layer if (layer.getSchema() != null) { SimpleFeatureType featureType = layer.getSchema(); //set the name of the feature type style for the feature renderer String name = featureType.getName().getLocalPart(); sldContentManager.getDefaultFeatureTypeStyle().setFeatureTypeName(SLDs.GENERIC_FEATURE_TYPENAME); } // force the toolbar to refresh // IToolBarManager tbm = getViewSite().getActionBars().getToolBarManager(); tbm.markDirty(); tbm.update(true); getViewSite().getActionBars().updateActionBars(); for (IContributionItem item : tbm.getItems()) { ActionContributionItem action = (ActionContributionItem) item; action.getAction().setEnabled(action.getAction().isEnabled()); } // focus the active editor if any exisits SLDEditorPart editor = (SLDEditorPart) editorBook.getData(); List<Class> supported = SLD.getSupportedTypes(layer); if (editor != null) { if (supported.contains(editor.getContentType())) { initEditor(editor); editor.reset(); return; // current editor is still okay } } // if we get here the current editor wasn't applicable, show first that works for (Class type : classToEditors.keySet()) { if (!supported.contains(type)) continue; for (SLDEditorPart part : classToEditors.get(type)) { initEditor(part); // FIXME: we don't want the editor to have content it should not part.reset(); editorBook.setData(part); editorBook.showPage(part.getPage()); part.getPage().setVisible(true); return; } } editorBook.showPage(blank); }