/**********************************************************************
- * Copyright (c) 2005, 2008, 2011 IBM Corporation and others.
+ * Copyright (c) 2005, 2012 IBM Corporation, Ericsson
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- * $Id: SDView.java,v 1.2 2008/01/24 02:29:01 apnan Exp $
- *
- * Contributors:
- * IBM - Initial API and implementation
- * Bernd Hufmann - Updated for TMF
+ *
+ * Contributors:
+ * IBM - Initial API and implementation
+ * Bernd Hufmann - Updated for TMF
**********************************************************************/
+
package org.eclipse.linuxtools.tmf.ui.views.uml2sd;
import java.util.Iterator;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.linuxtools.tmf.ui.ITmfImageConstants;
-import org.eclipse.linuxtools.tmf.ui.TmfUiPlugin;
+import org.eclipse.linuxtools.internal.tmf.ui.Activator;
+import org.eclipse.linuxtools.internal.tmf.ui.ITmfImageConstants;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.BaseMessage;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.Frame;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.Zoom.ZoomType;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.provider.IExtendedFilterProvider;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.provider.IExtendedFindProvider;
-import org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.provider.IPropertySheetPage;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.provider.ISDAdvancedPagingProvider;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.provider.ISDCollapseProvider;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.provider.ISDExtendedActionBarProvider;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.actions.ActionFactory;
import org.eclipse.ui.part.ViewPart;
+import org.eclipse.ui.views.properties.IPropertySheetPage;
/**
+ * <p>
+ * This class is a generic sequence diagram view implementation.
+ * </p>
+
+ * @version 1.0
* @author sveyrier
- *
*/
public class SDView extends ViewPart {
- protected SDWidget sdWidget = null;
- protected TimeCompressionBar timeCompressionBar = null;
- protected ISDFindProvider sdFindProvider = null;
- protected ISDPagingProvider sdPagingProvider = null;
- protected ISDFilterProvider sdFilterProvider = null;
- protected IExtendedFilterProvider sdExFilterProvider = null;
- protected IExtendedFindProvider sdExFindProvider = null;
- protected ISDExtendedActionBarProvider sdExtendedActionBarProvider = null;
- protected ISDPropertiesProvider sdPropertiesProvider = null;
-
- protected NextPage nextPageButton = null;
- protected PrevPage prevPageButton = null;
- protected FirstPage firstPageButton = null;
- protected LastPage lastPageButton = null;
-
- protected MenuManager menuMgr = null;
-
- protected boolean needInit = true;
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+ /**
+ * The sequence diagram widget.
+ */
+ protected SDWidget fSdWidget = null;
+ /**
+ * The time compression bar.
+ */
+ protected TimeCompressionBar fTimeCompressionBar = null;
+ /**
+ * The sequence diagram find provider implementation.
+ */
+ protected ISDFindProvider fSdFindProvider = null;
+ /**
+ * The sequence diagram paging provider implementation.
+ */
+ protected ISDPagingProvider fSdPagingProvider = null;
+ /**
+ * The sequence diagram filter provider implementation.
+ */
+ protected ISDFilterProvider fSdFilterProvider = null;
+ /**
+ * The extended sequence diagram filter provider implementation.
+ */
+ protected IExtendedFilterProvider fSdExFilterProvider = null;
+ /**
+ * The extended sequence diagram find provider implementation.
+ */
+ protected IExtendedFindProvider fSdExFindProvider = null;
+ /**
+ * The extended sequence diagram action bar provider implementation.
+ */
+ protected ISDExtendedActionBarProvider fSdExtendedActionBarProvider = null;
+ /**
+ * The sequence diagram property provider implementation.
+ */
+ protected ISDPropertiesProvider fSdPropertiesProvider = null;
+ /**
+ * Button for executing the next page action.
+ */
+ protected NextPage fNextPageButton = null;
+ /**
+ * Button for executing the previous page action.
+ */
+ protected PrevPage fPrevPageButton = null;
+ /**
+ * Button for executing the first page page action.
+ */
+ protected FirstPage fFirstPageButton = null;
+ /**
+ * Button for executing the last page action.
+ */
+ protected LastPage fLastPageButton = null;
+ /**
+ * The menu manager reference.
+ */
+ protected MenuManager fMenuMgr = null;
+ /**
+ * Flag to indicate whether view needs initialization or not.
+ */
+ protected boolean fNeedInit = true;
+ /**
+ * WaitCursor is the cursor to be displayed when long tasks are running
+ */
+ protected Cursor fWaitCursor;
+
+ // ------------------------------------------------------------------------
+ // Methods
+ // ------------------------------------------------------------------------
/*
* (non-Javadoc)
GridData timeLayoutdata = new GridData(GridData.GRAB_VERTICAL | GridData.VERTICAL_ALIGN_FILL);
timeLayoutdata.widthHint = 10;
GridData seqDiagLayoutData = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.VERTICAL_ALIGN_FILL);
- timeCompressionBar = new TimeCompressionBar(parent, SWT.NONE);
- timeCompressionBar.setLayoutData(timeLayoutdata);
- sdWidget = new SDWidget(parent, SWT.NONE);// SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
- sdWidget.setLayoutData(seqDiagLayoutData);
- sdWidget.setSite(this);
- sdWidget.setTimeBar(timeCompressionBar);
+ fTimeCompressionBar = new TimeCompressionBar(parent, SWT.NONE);
+ fTimeCompressionBar.setLayoutData(timeLayoutdata);
+ fSdWidget = new SDWidget(parent, SWT.NONE);// SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
+ fSdWidget.setLayoutData(seqDiagLayoutData);
+ fSdWidget.setSite(this);
+ fSdWidget.setTimeBar(fTimeCompressionBar);
// Add this view to the key bindings manager
KeyBindingsManager.getInstance().add(this.getSite().getId());
-
+
createCoolbarContent();
hookContextMenu();
- timeCompressionBar.setVisible(false);
+ fTimeCompressionBar.setVisible(false);
parent.layout(true);
Print print = new Print(this);
getViewSite().getActionBars().setGlobalActionHandler(ActionFactory.PRINT.getId(), print);
- needInit = restoreLoader();
+ fNeedInit = restoreLoader();
}
/**
- * Load a blank page that is supposed to explain that a kind of interaction must be chosen
+ * Load a blank page that is supposed to explain that a kind of interaction must be chosen.
*/
protected void loadBlank() {
- IUml2SDLoader l = new IUml2SDLoader() {
- /*
- * (non-Javadoc)
- * @see
- * org.eclipse.linuxtools.tmf.ui.views.uml2sd.load.IUml2SDLoader#setViewer(org.eclipse.linuxtools.tmf.ui
- * .views.uml2sd.SDView)
- */
- @Override
- public void setViewer(SDView viewer) {
- // Nothing to do
- Frame f = new Frame();
- f.setName(""); //$NON-NLS-1$
- viewer.setFrame(f);
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.load.IUml2SDLoader#getTitleString()
- */
- @Override
- public String getTitleString() {
- return ""; //$NON-NLS-1$
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.load.IUml2SDLoader#aboutToBeReplaced()
- */
- @Override
- public void dispose() {
- }
- };
- l.setViewer(this);
- setContentDescription(l.getTitleString());
+ IUml2SDLoader loader = new BlankUml2SdLoader();
+ loader.setViewer(this);
+ setContentDescription(loader.getTitleString());
}
/*
*/
@Override
public void setFocus() {
- if (sdWidget != null) {
+ if (fSdWidget != null) {
// update actions for key bindings
KeyBindingsManager.getInstance().setSdView(this);
- sdWidget.setFocus();
+ fSdWidget.setFocus();
}
- if (isViewReady() && needInit) {
- needInit = restoreLoader();
+ if (isViewReady() && fNeedInit) {
+ fNeedInit = restoreLoader();
}
}
}
/**
+ * Returns the SD widget.
+ *
* @return The SD widget.
*/
public SDWidget getSDWidget() {
- return sdWidget;
+ return fSdWidget;
}
-
+
/**
* Set the find provider for the opened sequence diagram viewer<br>
* If the provider is not set, the find menu item will not be available in the viewer<br>
* A find provider is called back when the user perform a find action<br>
- * The find provider is responsible to move the sequence diagram to the GraphNode which match the
+ * The find provider is responsible to move the sequence diagram to the GraphNode which match the
* find criteria as well as to highlight the GraphNode
- *
+ *
* @param provider the search provider
*/
public void setSDFindProvider(ISDFindProvider provider) {
- sdFindProvider = provider;
- sdExFindProvider = null;
+ fSdFindProvider = provider;
+ fSdExFindProvider = null;
createCoolbarContent();
if (provider != null) {
KeyBindingsManager.getInstance().setFindEnabled(true);
/**
* Set the find provider for the opened sequence diagram viewer<br>
- * If the provider is not set, the find menu item will not be available in the viewer<br>
+ * If the provider is not set, the find menu item will not be available in
+ * the viewer<br>
* A find provider is called back when the user perform a find action<br>
- * If the extended find provider is set, it replaces the regular find provider (sdFindProvider).<br>
+ * If the extended find provider is set, it replaces the regular find
+ * provider (sdFindProvider).<br>
+ *
* @param provider
+ * The provider to set
*/
public void setExtendedFindProvider(IExtendedFindProvider provider) {
- sdExFindProvider = provider;
- sdFindProvider = null;
+ fSdExFindProvider = provider;
+ fSdFindProvider = null;
createCoolbarContent();
if (provider != null) {
KeyBindingsManager.getInstance().setFindEnabled(true);
/**
* Returns the extended find provider
- *
+ *
* @return extended find provider.
*/
public IExtendedFindProvider getExtendedFindProvider() {
- return sdExFindProvider;
+ return fSdExFindProvider;
}
/**
*/
public void resetProviders() {
KeyBindingsManager.getInstance().setFindEnabled(false);
- sdFindProvider = null;
- sdExFindProvider = null;
- sdFilterProvider = null;
- sdExFilterProvider = null;
- sdPagingProvider = null;
- sdExtendedActionBarProvider = null;
- sdPropertiesProvider = null;
- if ((sdWidget != null) && (!sdWidget.isDisposed())) {
- sdWidget.setCollapseProvider(null);
+ fSdFindProvider = null;
+ fSdExFindProvider = null;
+ fSdFilterProvider = null;
+ fSdExFilterProvider = null;
+ fSdPagingProvider = null;
+ fSdExtendedActionBarProvider = null;
+ fSdPropertiesProvider = null;
+ if ((fSdWidget != null) && (!fSdWidget.isDisposed())) {
+ fSdWidget.setCollapseProvider(null);
}
}
* Set the filter provider for the opened sequence diagram viewer<br>
* If the provider is not set, the filter menu item will not be available in the viewer<br>
* A filter provider is called back when the user perform a filter action<br>
- *
+ *
* @param provider the filter provider
*/
public void setSDFilterProvider(ISDFilterProvider provider) {
- sdFilterProvider = provider;
+ fSdFilterProvider = provider;
// Both systems can be used now, commenting out next statement
// sdExFilterProvider = null;
createCoolbarContent();
}
-
+
/**
- * Sets the extended filter provider for the opend sequence diagram viewer.
+ * Sets the extended filter provider for the opened sequence diagram viewer.
+ *
* @param provider
+ * The provider to set
*/
public void setExtendedFilterProvider(IExtendedFilterProvider provider) {
- sdExFilterProvider = provider;
+ fSdExFilterProvider = provider;
// Both systems can be used now, commenting out next statement
// sdFilterProvider = null;
createCoolbarContent();
/**
* Returns the extended find provider.
- *
+ *
* @return The extended find provider.
*/
public IExtendedFilterProvider getExtendedFilterProvider() {
- return sdExFilterProvider;
+ return fSdExFilterProvider;
}
/**
- * Register the given provider to support Drag and Drop collapsing. This provider is
+ * Register the given provider to support Drag and Drop collapsing. This provider is
* responsible of updating the Frame.
- *
+ *
* @param provider - the provider to register
*/
public void setCollapsingProvider(ISDCollapseProvider provider) {
- if ((sdWidget != null) && (!sdWidget.isDisposed())) {
- sdWidget.setCollapseProvider(provider);
+ if ((fSdWidget != null) && (!fSdWidget.isDisposed())) {
+ fSdWidget.setCollapseProvider(provider);
}
}
* If the sequence diagram provided (see setFrame) need to be split in many parts, a paging provider must be
* provided in order to handle page change requested by the user<br>
* Set a page provider will create the next and previous page buttons in the viewer coolBar
- *
+ *
* @param provider the paging provider
*/
public void setSDPagingProvider(ISDPagingProvider provider) {
- sdPagingProvider = provider;
+ fSdPagingProvider = provider;
createCoolbarContent();
}
/**
* Returns the current page provider for the view
- *
+ *
* @return the paging provider
*/
public ISDPagingProvider getSDPagingProvider() {
- return sdPagingProvider;
+ return fSdPagingProvider;
}
/**
* Returns the current find provider for the view
- *
+ *
* @return the find provider
*/
public ISDFindProvider getSDFindProvider() {
- return sdFindProvider;
+ return fSdFindProvider;
}
/**
* Returns the current filter provider for the view
- *
+ *
* @return the filter provider
*/
public ISDFilterProvider getSDFilterProvider() {
- return sdFilterProvider;
+ return fSdFilterProvider;
}
/**
* Set the extended action bar provider for the opened sequence diagram viewer<br>
* This allow to add programmatically actions in the coolbar and/or in the drop-down menu
- *
+ *
* @param provider the search provider
*/
public void setSDExtendedActionBarProvider(ISDExtendedActionBarProvider provider) {
- sdExtendedActionBarProvider = provider;
+ fSdExtendedActionBarProvider = provider;
createCoolbarContent();
}
/**
* Returns the current extended action bar provider for the view
- *
+ *
* @return the extended action bar provider
*/
public ISDExtendedActionBarProvider getSDExtendedActionBarProvider() {
- return sdExtendedActionBarProvider;
+ return fSdExtendedActionBarProvider;
}
/**
- * Set the properties view provider for the opened sequence diagram viewer<br>
- *
+ * Set the properties view provider for the opened sequence diagram viewer
+ *
* @param provider the properties provider
*/
public void setSDPropertiesProvider(ISDPropertiesProvider provider) {
- sdPropertiesProvider = provider;
+ fSdPropertiesProvider = provider;
}
/**
- * Returns the current extended action bar provider for the view
- *
+ * Returns the current extended action bar provider for the view.
+ *
* @return the extended action bar provider
*/
public ISDPropertiesProvider getSDPropertiesProvider() {
- return sdPropertiesProvider;
+ return fSdPropertiesProvider;
}
/**
* Creates the basic sequence diagram menu
*/
protected void hookContextMenu() {
- menuMgr = new MenuManager("#PopupMenu"); //$NON-NLS-1$
- menuMgr.setRemoveAllWhenShown(true);
- menuMgr.addMenuListener(new IMenuListener() {
+ fMenuMgr = new MenuManager("#PopupMenu"); //$NON-NLS-1$
+ fMenuMgr.setRemoveAllWhenShown(true);
+ fMenuMgr.addMenuListener(new IMenuListener() {
@Override
public void menuAboutToShow(IMenuManager manager) {
fillContextMenu(manager);
}
});
- Menu menu = menuMgr.createContextMenu(sdWidget.getViewControl());
- sdWidget.getViewControl().setMenu(menu);
- getSite().registerContextMenu(menuMgr, sdWidget.getSelectionProvider());
+ Menu menu = fMenuMgr.createContextMenu(fSdWidget.getViewControl());
+ fSdWidget.getViewControl().setMenu(menu);
+ getSite().registerContextMenu(fMenuMgr, fSdWidget.getSelectionProvider());
}
/**
* Returns the context menu manager
- *
+ *
* @return the menu manager
*/
public MenuManager getMenuManager() {
- return menuMgr;
+ return fMenuMgr;
}
/**
* Fills the basic sequence diagram menu and define the dynamic menu item insertion point
- *
+ *
* @param manager the menu manager
*/
protected void fillContextMenu(IMenuManager manager) {
manager.add(new Separator("Additions")); //$NON-NLS-1$
- if (getSDWidget() != null && getSDWidget().currentGraphNode != null) {
- ISelectionProvider selProvider = sdWidget.getSelectionProvider();
+ if (getSDWidget() != null && getSDWidget().fCurrentGraphNode != null) {
+ ISelectionProvider selProvider = fSdWidget.getSelectionProvider();
ISelection sel = selProvider.getSelection();
int nbMessage = 0;
Iterator<?> it = ((StructuredSelection) sel).iterator();
if (nbMessage != 1) {
return;
}
- GraphNode node = getSDWidget().currentGraphNode;
- if (node instanceof SyncMessageReturn) {
- if (((SyncMessageReturn) node).getMessage() != null) {
- Action goToMessage = new MoveToMessage(this);
- goToMessage.setText(SDMessages._39);
- manager.add(goToMessage);
- }
+ GraphNode node = getSDWidget().fCurrentGraphNode;
+ if ((node instanceof SyncMessageReturn) && (((SyncMessageReturn) node).getMessage() != null)) {
+ Action goToMessage = new MoveToMessage(this);
+ goToMessage.setText(SDMessages._39);
+ manager.add(goToMessage);
}
- if (node instanceof SyncMessage) {
- if (((SyncMessage) node).getMessageReturn() != null) {
- Action goToMessage = new MoveToMessage(this);
- goToMessage.setText(SDMessages._40);
- manager.add(goToMessage);
- }
+ if ((node instanceof SyncMessage) && (((SyncMessage) node).getMessageReturn() != null)) {
+ Action goToMessage = new MoveToMessage(this);
+ goToMessage.setText(SDMessages._40);
+ manager.add(goToMessage);
}
}
manager.add(new Separator("MultiSelectAdditions")); //$NON-NLS-1$
/**
* Enables/Disables an action with given name.
- *
+ *
* @param actionName The action name
* @param state true or false
*/
* Creates the coolBar icon depending on the actions supported by the Sequence Diagram provider<br>
* - Navigation buttons are displayed if ISDPovider.HasPaging return true<br>
* - Navigation buttons are enabled depending on the value return by ISDPovider.HasNext and HasPrev<br>
- *
+ *
* @see ISDGraphNodeSupporter Action support definition
* @see SDView#setSDFilterProvider(ISDFilterProvider)
* @see SDView#setSDFindProvider(ISDFindProvider)
minMax.setId("org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.ConfigureMinMax");//$NON-NLS-1$
bar.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", minMax); //$NON-NLS-1$
- if ((sdWidget.getFrame() != null) && (sdWidget.getFrame().hasTimeInfo()))
+ if ((fSdWidget.getFrame() != null) && (fSdWidget.getFrame().hasTimeInfo())) {
minMax.setEnabled(true);
- else
+ } else {
minMax.setEnabled(false);
+ }
// Do we need to display a paging item
- if (sdPagingProvider != null) {
- nextPageButton = new NextPage(this);
- bar.getToolBarManager().appendToGroup("UML2SD_OTHER_COMMANDS", nextPageButton); //$NON-NLS-1$
- nextPageButton.setEnabled(sdPagingProvider.hasNextPage());
- bar.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", nextPageButton); //$NON-NLS-1$
-
- prevPageButton = new PrevPage(this);
- bar.getToolBarManager().appendToGroup("UML2SD_OTHER_COMMANDS", prevPageButton); //$NON-NLS-1$
- prevPageButton.setEnabled(sdPagingProvider.hasPrevPage());
- bar.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", prevPageButton); //$NON-NLS-1$
-
- firstPageButton = new FirstPage(this);
- bar.getToolBarManager().appendToGroup("UML2SD_OTHER_COMMANDS", firstPageButton); //$NON-NLS-1$
- firstPageButton.setEnabled(sdPagingProvider.hasPrevPage());
- bar.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", firstPageButton); //$NON-NLS-1$
-
- lastPageButton = new LastPage(this);
- bar.getToolBarManager().appendToGroup("UML2SD_OTHER_COMMANDS", lastPageButton); //$NON-NLS-1$
- lastPageButton.setEnabled(sdPagingProvider.hasNextPage());
- bar.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", lastPageButton); //$NON-NLS-1$
- }
-
- if (sdExFilterProvider != null) {
- Action action = sdExFilterProvider.getFilterAction();
+ if (fSdPagingProvider != null) {
+ fNextPageButton = new NextPage(this);
+ bar.getToolBarManager().appendToGroup("UML2SD_OTHER_COMMANDS", fNextPageButton); //$NON-NLS-1$
+ fNextPageButton.setEnabled(fSdPagingProvider.hasNextPage());
+ bar.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", fNextPageButton); //$NON-NLS-1$
+
+ fPrevPageButton = new PrevPage(this);
+ bar.getToolBarManager().appendToGroup("UML2SD_OTHER_COMMANDS", fPrevPageButton); //$NON-NLS-1$
+ fPrevPageButton.setEnabled(fSdPagingProvider.hasPrevPage());
+ bar.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", fPrevPageButton); //$NON-NLS-1$
+
+ fFirstPageButton = new FirstPage(this);
+ bar.getToolBarManager().appendToGroup("UML2SD_OTHER_COMMANDS", fFirstPageButton); //$NON-NLS-1$
+ fFirstPageButton.setEnabled(fSdPagingProvider.hasPrevPage());
+ bar.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", fFirstPageButton); //$NON-NLS-1$
+
+ fLastPageButton = new LastPage(this);
+ bar.getToolBarManager().appendToGroup("UML2SD_OTHER_COMMANDS", fLastPageButton); //$NON-NLS-1$
+ fLastPageButton.setEnabled(fSdPagingProvider.hasNextPage());
+ bar.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", fLastPageButton); //$NON-NLS-1$
+ }
+
+ if (fSdExFilterProvider != null) {
+ Action action = fSdExFilterProvider.getFilterAction();
if (action != null) {
if (action.getId() == null)
+ {
action.setId("org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.extendedFilter"); //$NON-NLS-1$
- if (action.getImageDescriptor() == null)
- action.setImageDescriptor(TmfUiPlugin.getDefault().getImageDescripterFromPath(ITmfImageConstants.IMG_UI_FILTERS));
- if (action.getText() == null || action.getText().length() == 0)
+ }
+ if (action.getImageDescriptor() == null) {
+ action.setImageDescriptor(Activator.getDefault().getImageDescripterFromPath(ITmfImageConstants.IMG_UI_FILTERS));
+ }
+ if (action.getText() == null || action.getText().length() == 0) {
action.setText(SDMessages._42);
+ }
bar.getMenuManager().prependToGroup("UML2SD_FILTERING", action); //$NON-NLS-1$
bar.getToolBarManager().prependToGroup("UML2SD_FILTERING", action); //$NON-NLS-1$
}
}
// Both systems can be used now: commenting out else keyword
- /* else */if (sdFilterProvider != null) {
- bar.getMenuManager().appendToGroup("UML2SD_FILTERING", new OpenSDFiltersDialog(this, sdFilterProvider)); //$NON-NLS-1$
+ /* else */if (fSdFilterProvider != null) {
+ bar.getMenuManager().appendToGroup("UML2SD_FILTERING", new OpenSDFiltersDialog(this, fSdFilterProvider)); //$NON-NLS-1$
// No longer in the coolbar: commenting out next statement
- //bar.getToolBarManager().appendToGroup("UML2SD_FILTERING",new OpenSDFiltersDialog(this, sdFilterProvider)); //$NON-NLS-1$
+ //bar.getToolBarManager().appendToGroup("UML2SD_FILTERING",new OpenSDFiltersDialog(this, sdFilterProvider)); //$NON-NLS-1$
}
- if (sdPagingProvider != null && sdPagingProvider instanceof ISDAdvancedPagingProvider) {
+ if (fSdPagingProvider instanceof ISDAdvancedPagingProvider) {
IContributionItem sdPaging = bar.getMenuManager().find(OpenSDPagesDialog.ID);
if (sdPaging != null) {
bar.getMenuManager().remove(sdPaging);
sdPaging = null;
}
- bar.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", new OpenSDPagesDialog(this, (ISDAdvancedPagingProvider) sdPagingProvider)); //$NON-NLS-1$
+ bar.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", new OpenSDPagesDialog(this, (ISDAdvancedPagingProvider) fSdPagingProvider)); //$NON-NLS-1$
updatePagesMenuItem(bar);
}
- if (sdExFindProvider != null) {
- Action action = sdExFindProvider.getFindAction();
+ if (fSdExFindProvider != null) {
+ Action action = fSdExFindProvider.getFindAction();
if (action != null) {
- if (action.getId() == null)
+ if (action.getId() == null) {
action.setId("org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.extendedFind"); //$NON-NLS-1$
- if (action.getImageDescriptor() == null)
- action.setImageDescriptor(TmfUiPlugin.getDefault().getImageDescripterFromPath(ITmfImageConstants.IMG_UI_SEARCH_SEQ));
- if (action.getText() == null)
+ }
+ if (action.getImageDescriptor() == null) {
+ action.setImageDescriptor(Activator.getDefault().getImageDescripterFromPath(ITmfImageConstants.IMG_UI_SEARCH_SEQ));
+ }
+ if (action.getText() == null) {
action.setText(SDMessages._41);
+ }
bar.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", action); //$NON-NLS-1$
bar.getToolBarManager().appendToGroup("UML2SD_OTHER_COMMANDS", action); //$NON-NLS-1$
}
- } else if (sdFindProvider != null) {
+ } else if (fSdFindProvider != null) {
bar.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", new OpenSDFindDialog(this)); //$NON-NLS-1$
bar.getToolBarManager().appendToGroup("UML2SD_OTHER_COMMANDS", new OpenSDFindDialog(this)); //$NON-NLS-1$
}
- if (sdExtendedActionBarProvider != null) {
- sdExtendedActionBarProvider.supplementCoolbarContent(bar);
+ if (fSdExtendedActionBarProvider != null) {
+ fSdExtendedActionBarProvider.supplementCoolbarContent(bar);
}
bar.updateActionBars();
* Updates the view coolbar buttons state according to the value return by: -
* ISDExtendedActionBarProvider.hasNextPage()<br>
* - ISDExtendedActionBarProvider.hasPrevPage()<br>
- *
+ *
*/
public void updateCoolBar() {
- if (sdPagingProvider != null) {
+ if (fSdPagingProvider != null) {
IActionBars bar = getViewSite().getActionBars();
- if (bar == null)
+ if (bar == null) {
return;
+ }
IToolBarManager barManager = bar.getToolBarManager();
- if (barManager == null)
+ if (barManager == null) {
return;
+ }
IContributionItem nextPage = barManager.find(NextPage.ID);
- if (nextPage != null && nextPage instanceof ActionContributionItem) {
+ if (nextPage instanceof ActionContributionItem) {
IAction nextPageAction = ((ActionContributionItem) nextPage).getAction();
- if (nextPageAction != null && nextPageAction instanceof NextPage) {
- ((NextPage) nextPageAction).setEnabled(sdPagingProvider.hasNextPage());
+ if (nextPageAction instanceof NextPage) {
+ ((NextPage) nextPageAction).setEnabled(fSdPagingProvider.hasNextPage());
}
}
IContributionItem prevPage = barManager.find(PrevPage.ID);
- if (prevPage != null && prevPage instanceof ActionContributionItem) {
+ if (prevPage instanceof ActionContributionItem) {
IAction prevPageAction = ((ActionContributionItem) prevPage).getAction();
- if (prevPageAction != null && prevPageAction instanceof PrevPage) {
- ((PrevPage) prevPageAction).setEnabled(sdPagingProvider.hasPrevPage());
+ if (prevPageAction instanceof PrevPage) {
+ ((PrevPage) prevPageAction).setEnabled(fSdPagingProvider.hasPrevPage());
}
}
IContributionItem firstPage = barManager.find(FirstPage.ID);
- if (firstPage != null && firstPage instanceof ActionContributionItem) {
+ if (firstPage instanceof ActionContributionItem) {
IAction firstPageAction = ((ActionContributionItem) firstPage).getAction();
- if (firstPageAction != null && firstPageAction instanceof FirstPage) {
- ((FirstPage) firstPageAction).setEnabled(sdPagingProvider.hasPrevPage());
+ if (firstPageAction instanceof FirstPage) {
+ ((FirstPage) firstPageAction).setEnabled(fSdPagingProvider.hasPrevPage());
}
}
IContributionItem lastPage = barManager.find(LastPage.ID);
- if (lastPage != null && lastPage instanceof ActionContributionItem) {
+ if (lastPage instanceof ActionContributionItem) {
IAction lastPageAction = ((ActionContributionItem) lastPage).getAction();
- if (lastPageAction != null && lastPageAction instanceof LastPage) {
- ((LastPage) lastPageAction).setEnabled(sdPagingProvider.hasNextPage());
+ if (lastPageAction instanceof LastPage) {
+ ((LastPage) lastPageAction).setEnabled(fSdPagingProvider.hasNextPage());
}
}
-
+
updatePagesMenuItem(bar);
}
}
/**
* Enables or disables the Pages... menu item, depending on the number of pages
- *
+ *
* @param bar the bar containing the action
*/
protected void updatePagesMenuItem(IActionBars bar) {
- if (sdPagingProvider instanceof ISDAdvancedPagingProvider) {
+ if (fSdPagingProvider instanceof ISDAdvancedPagingProvider) {
IMenuManager menuManager = bar.getMenuManager();
ActionContributionItem contributionItem = (ActionContributionItem) menuManager.find(OpenSDPagesDialog.ID);
IAction openSDPagesDialog = null;
openSDPagesDialog = contributionItem.getAction();
}
- if (openSDPagesDialog != null && openSDPagesDialog instanceof OpenSDPagesDialog) {
- openSDPagesDialog.setEnabled(((ISDAdvancedPagingProvider) sdPagingProvider).pagesCount() > 1);
+ if (openSDPagesDialog instanceof OpenSDPagesDialog) {
+ openSDPagesDialog.setEnabled(((ISDAdvancedPagingProvider) fSdPagingProvider).pagesCount() > 1);
}
}
}
/**
* The frame to render (the sequence diagram)
- *
+ *
* @param frame the frame to display
*/
public void setFrame(Frame frame) {
/**
* The frame to render (the sequence diagram)
- *
+ *
* @param frame the frame to display
+ * @param resetPosition boolean Flag whether to reset the position or not.
*/
protected void setFrame(Frame frame, boolean resetPosition) {
- if (sdWidget == null)
+ if (getSDWidget() == null) {
return;
+ }
if (frame == null) {
loadBlank();
return;
}
- IUml2SDLoader l = LoadersManager.getInstance().getCurrentLoader(getViewSite().getId(), this);
+ IUml2SDLoader loader = LoadersManager.getInstance().getCurrentLoader(getViewSite().getId(), this);
+ if (loader == null) {
+ return;
+ }
- if ((l != null) && (l.getTitleString() != null)) {
- setContentDescription(l.getTitleString());
+ if (loader.getTitleString() != null) {
+ setContentDescription(loader.getTitleString());
}
- if (getSDWidget() != null)
- getSDWidget().setFrame(frame, resetPosition);
+ getSDWidget().setFrame(frame, resetPosition);
- if (timeCompressionBar != null)
- timeCompressionBar.setFrame(frame);
+ if (fTimeCompressionBar != null) {
+ fTimeCompressionBar.setFrame(frame);
+ }
updateCoolBar();
- if (!frame.hasTimeInfo()) {
- Composite parent = timeCompressionBar.getParent();
- timeCompressionBar.setVisible(false);
- parent.layout(true);
- } else {
- Composite parent = timeCompressionBar.getParent();
- timeCompressionBar.setVisible(true);
- parent.layout(true);
+ if (fTimeCompressionBar != null) {
+ if (!frame.hasTimeInfo()) {
+ Composite parent = fTimeCompressionBar.getParent();
+ fTimeCompressionBar.setVisible(false);
+ parent.layout(true);
+ } else {
+ Composite parent = fTimeCompressionBar.getParent();
+ fTimeCompressionBar.setVisible(true);
+ parent.layout(true);
+ }
}
IContributionItem shortKeysMenu = getViewSite().getActionBars().getMenuManager().find("org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers");//$NON-NLS-1$
MenuManager shortKeys = (MenuManager) shortKeysMenu;
for (int i = 0; i < items.length; i++) {
if (items[i] instanceof ActionContributionItem) {
IAction action = ((ActionContributionItem) items[i]).getAction();
- if (action != null)
+ if (action != null) {
action.setEnabled(true);
+ }
}
}
}
/**
* Activate or deactivate the short key command given in parameter (see plugin.xml)
- *
+ *
* @param id the command id defined in the plugin.xml
* @param value the state value
*/
public void setEnableCommand(String id, boolean value) {
IContributionItem shortKeysMenu = getViewSite().getActionBars().getMenuManager().find("org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers");//$NON-NLS-1$
MenuManager shortKeys = (MenuManager) shortKeysMenu;
- if (shortKeys == null)
+ if (shortKeys == null) {
return;
+ }
IContributionItem item = shortKeys.find(id);
if ((item != null) && (item instanceof ActionContributionItem)) {
IAction action = ((ActionContributionItem) item).getAction();
- if (action != null)
+ if (action != null) {
action.setEnabled(value);
+ }
}
}
/**
* Set the frame from an other thread than the one executing the main loop
- *
- * @param frame
+ *
+ * @param frame The frame to set (and display)
*/
public void setFrameSync(final Frame frame) {
if (getSDWidget() == null || getSDWidget().isDisposed()) {
getSDWidget().getDisplay().syncExec(new Runnable() {
@Override
public void run() {
- if (getSDWidget() == null || getSDWidget().isDisposed()) {
+ if (getSDWidget() == null || getSDWidget().isDisposed() ||
+ ((fTimeCompressionBar != null) && fTimeCompressionBar.isDisposed())) {
return;
}
setFrame(frame);
/**
* Ensure an object is visible from an other thread than the one executing the main loop
- *
- * @param sm
+ *
+ * @param sm The node to make visible in view
*/
public void ensureVisibleSync(final GraphNode sm) {
getSDWidget().getDisplay().syncExec(new Runnable() {
/**
* Set the frame and ensure an object is visible from an other thread than the one executing the main loop
- *
- * @param sm
+ *
+ * @param sm The node to make visible in view
+ * @param frame Frame The frame to set
*/
public void setFrameAndEnsureVisibleSync(final Frame frame, final GraphNode sm) {
if (getSDWidget() == null || getSDWidget().isDisposed()) {
/**
* Set the frame and ensure an object is visible
- *
- * @param sm
+ *
+ * @param sm The node to make visible in view
+ * @param frame Frame The frame to set
*/
public void setFrameAndEnsureVisible(Frame frame, GraphNode sm) {
getSDWidget().clearSelection();
/**
* Set the frame and ensure an object is visible from an other thread than the one executing the main loop
- *
- * @param sm
+ *
+ * @param frame The frame to set.
+ * @param x The x coordinate to make visible.
+ * @param y The y coordinate to make visible.
*/
public void setFrameAndEnsureVisibleSync(final Frame frame, final int x, final int y) {
if (getSDWidget() == null || getSDWidget().isDisposed()) {
return;
}
-
+
getSDWidget().getDisplay().syncExec(new Runnable() {
@Override
public void run() {
/**
* Set the frame and ensure an object is visible
- *
- * @param sm
+ *
+ * @param frame The frame to set.
+ * @param x The x coordinate to make visible.
+ * @param y The y coordinate to make visible.
*/
public void setFrameAndEnsureVisible(Frame frame, int x, int y) {
getSDWidget().clearSelection();
getSDWidget().redraw();
}
- /**
- * waitCursor is the cursor to be displayed when long tasks are running
- */
- protected Cursor waitCursor;
-
/**
* Toggle between default and wait cursors from an other thread than the one executing the main loop
+ *
+ * @param wait <code>true</code> for wait cursor else <code>false</code> for default cursor.
*/
- public void toggleWaitCursorAsync(final boolean wait_) {
+ public void toggleWaitCursorAsync(final boolean wait) {
if (getSDWidget() == null || getSDWidget().isDisposed()) {
return;
}
if (getSDWidget() == null || getSDWidget().isDisposed()) {
return;
}
- if (wait_) {
- if (waitCursor != null && !waitCursor.isDisposed()) {
- waitCursor.dispose();
+ if (wait) {
+ if (fWaitCursor != null && !fWaitCursor.isDisposed()) {
+ fWaitCursor.dispose();
}
- waitCursor = new Cursor(getSDWidget().getDisplay(), SWT.CURSOR_WAIT);
- getSDWidget().setCursor(waitCursor);
+ fWaitCursor = new Cursor(getSDWidget().getDisplay(), SWT.CURSOR_WAIT);
+ getSDWidget().setCursor(fWaitCursor);
getSDWidget().getDisplay().update();
} else {
- if (waitCursor != null && !waitCursor.isDisposed()) {
- waitCursor.dispose();
+ if (fWaitCursor != null && !fWaitCursor.isDisposed()) {
+ fWaitCursor.dispose();
}
- waitCursor = null;
+ fWaitCursor = null;
getSDWidget().setCursor(null);
getSDWidget().getDisplay().update();
}
/**
* Return the time compression bar widget
- *
+ *
* @return the time compression bar
*/
public TimeCompressionBar getTimeCompressionBar() {
- return timeCompressionBar;
+ return fTimeCompressionBar;
}
/**
* Returns the current Frame (the sequence diagram container)
- *
- * @return the frame
+ *
+ * @return the current frame
*/
public Frame getFrame() {
if (getSDWidget() != null) {
return getSDWidget().getFrame();
}
- else {
- return null;
- }
+ return null;
}
+ /**
+ * Restores the loader for the view based on the view ID.
+ *
+ * @return boolean <code>true</code> if initialization is needed else <code>false</code>.
+ */
protected boolean restoreLoader() {
String id = getViewSite().getId();
// System.err.println("restoreLoader() id="+id);
if (id == null) {
return true;
}
- IUml2SDLoader l = LoadersManager.getInstance().getCurrentLoader(id, this);
+ IUml2SDLoader loader = LoadersManager.getInstance().getCurrentLoader(id, this);
// System.err.println("restoreLoader() l="+l);
- if ((l != null)) {// &&( LoadersManager.getLoadersManager().getViewer(l)==this)){
- l.setViewer(this);
+ if ((loader != null)) {// &&( LoadersManager.getLoadersManager().getViewer(l)==this)){
+ loader.setViewer(this);
return false;
- } else {
- loadBlank();
- return true;
}
+ loadBlank();
+ return true;
}
+ /**
+ * Checks if current view is ready to be used.
+ *
+ * @return boolean <code>true</code> if view is ready else <code>false</code>.
+ */
protected boolean isViewReady() {
- IWorkbenchPage persp = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
- if (persp == null)
+ IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ if (page == null) {
return false;
+ }
- IViewReference[] ref = persp.getViewReferences();
+ IViewReference[] ref = page.getViewReferences();
for (int i = 0; i < ref.length; i++) {
if (ref[i].getView(false) == this) {
return true;
return false;
}
+ /**
+ * Creates the menu group.
+ */
protected void createMenuGroup() {
IActionBars bar = getViewSite().getActionBars();
if (bar == null) {
bar.getMenuManager().add(new Separator("UML2SD_OTHER_PLUGINS_COMMANDS")); //$NON-NLS-1$
}
- @SuppressWarnings("rawtypes")
+ /*
+ * Gets adapter for this view for properties.
+ * (non-Javadoc)
+ * @see org.eclipse.ui.part.WorkbenchPart#getAdapter(java.lang.Class)
+ */
@Override
- public Object getAdapter(Class _adapter) {
- Object obj = super.getAdapter(_adapter);
- if (sdPropertiesProvider != null && _adapter.equals(IPropertySheetPage.class)) {
- return sdPropertiesProvider.getPropertySheetEntry();
+ public Object getAdapter(Class adapter) {
+ Object obj = super.getAdapter(adapter);
+ if (fSdPropertiesProvider != null && adapter.equals(IPropertySheetPage.class)) {
+ return fSdPropertiesProvider.getPropertySheetEntry();
}
return obj;
}
+
+ /**
+ * Loader for a blank sequence diagram.
+ *
+ * @version 1.0
+ */
+ public static class BlankUml2SdLoader implements IUml2SDLoader {
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.load.IUml2SDLoader#setViewer(org.eclipse.linuxtools.tmf.ui.views.uml2sd.SDView)
+ */
+ @Override
+ public void setViewer(SDView viewer) {
+ // Nothing to do
+ Frame f = new Frame();
+ f.setName(""); //$NON-NLS-1$
+ viewer.setFrame(f);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.load.IUml2SDLoader#getTitleString()
+ */
+ @Override
+ public String getTitleString() {
+ return ""; //$NON-NLS-1$
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.load.IUml2SDLoader#dispose()
+ */
+ @Override
+ public void dispose() {
+ }
+ }
}