use of com.archimatetool.model.viewpoints.IViewpoint in project archi by archimatetool.
the class ArchimateDiagramEditorActionBarContributor method createViewMenu.
@Override
protected IMenuManager createViewMenu(IMenuManager menuManager) {
IMenuManager viewMenu = super.createViewMenu(menuManager);
// Viewpoints
IMenuManager viewPointMenu = new MenuManager(Messages.ArchimateDiagramEditorActionBarContributor_0);
viewMenu.add(viewPointMenu);
for (IViewpoint viewPoint : ViewpointManager.INSTANCE.getAllViewpoints()) {
viewPointMenu.add(getAction(viewPoint.toString()));
}
return viewMenu;
}
use of com.archimatetool.model.viewpoints.IViewpoint in project archi by archimatetool.
the class ViewpointSection method update.
@Override
protected void update() {
if (fIsExecutingCommand) {
return;
}
String id = ((IArchimateDiagramModel) getFirstSelectedObject()).getViewpoint();
IViewpoint viewPoint = ViewpointManager.INSTANCE.getViewpoint(id);
// A Viewer will get a selectionChanged event when setting it
fIsRefreshing = true;
fComboViewer.setSelection(new StructuredSelection(viewPoint));
fIsRefreshing = false;
}
use of com.archimatetool.model.viewpoints.IViewpoint in project archi by archimatetool.
the class ViewpointSection method createControls.
@Override
protected void createControls(Composite parent) {
createLabel(parent, Messages.ViewpointSection_0, ITabbedLayoutConstants.STANDARD_LABEL_WIDTH, SWT.CENTER);
fComboViewer = new ComboViewer(new Combo(parent, SWT.READ_ONLY | SWT.BORDER));
fComboViewer.getCombo().setVisibleItemCount(12);
fComboViewer.getControl().setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
getWidgetFactory().adapt(fComboViewer.getControl(), true, true);
fComboViewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
if (fIsRefreshing) {
// A Viewer will get a selectionChanged event when setting it
return;
}
IViewpoint viewPoint = (IViewpoint) ((IStructuredSelection) event.getSelection()).getFirstElement();
if (viewPoint != null) {
CompoundCommand result = new CompoundCommand();
for (EObject diagramModel : getEObjects()) {
if (isAlive(diagramModel)) {
Command cmd = new EObjectFeatureCommand(Messages.ViewpointSection_1, diagramModel, IArchimatePackage.Literals.ARCHIMATE_DIAGRAM_MODEL__VIEWPOINT, viewPoint.getID());
if (cmd.canExecute()) {
result.add(cmd);
}
}
}
executeCommand(result.unwrap());
}
}
});
fComboViewer.setContentProvider(new IStructuredContentProvider() {
@Override
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
}
@Override
public void dispose() {
}
@Override
public Object[] getElements(Object inputElement) {
return ViewpointManager.INSTANCE.getAllViewpoints().toArray();
}
});
fComboViewer.setLabelProvider(new LabelProvider() {
@Override
public String getText(Object element) {
return ((IViewpoint) element).getName();
}
});
// $NON-NLS-1$
fComboViewer.setInput("");
// Help ID
PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, HELP_ID);
}
use of com.archimatetool.model.viewpoints.IViewpoint in project archi by archimatetool.
the class ZestViewerContentProviderTests method testSetViewpointFilter.
@Test
public void testSetViewpointFilter() {
// Default VP
IViewpoint defaultViewpoint = ViewpointManager.NONE_VIEWPOINT;
assertTrue(provider.getViewpointFilter() == defaultViewpoint);
provider.setViewpointFilter(ViewpointManager.INSTANCE.getAllViewpoints().get(1));
assertSame(provider.getViewpointFilter(), ViewpointManager.INSTANCE.getAllViewpoints().get(1));
// Back to default
provider.setViewpointFilter(defaultViewpoint);
}
Aggregations