Skip to content

Commit

Permalink
#2310 Speedup Capella Startup - ImageDescriptors
Browse files Browse the repository at this point in the history
AbstractUIPlugin.imageDescriptorFromPlugin is used to replace
Activators.getDefault() used to retrieve imageDescriptors.

Change-Id: I0000000000000000000000000000000000000000
Signed-off-by: Arnaud Dieumegard <[email protected]>
  • Loading branch information
arnauddieumegard committed Jan 19, 2022
1 parent ace802a commit 9f9724c
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 97 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,12 @@ protected int getNbColumn() {
protected void initializeControls(final Composite parent, final IRendererContext context) {
super.initializeControls(parent, context);

ToolBar toolbar = new ToolBar(parent, SWT.HORIZONTAL);
ToolBar toolbar = new ToolBar(parent, SWT.HORIZONTAL);
final String ICONS_PATH = "icons/"; //$NON-NLS-1$
if (isBrowseButton()) {
browse = new ToolItem(toolbar, SWT.PUSH);
browse.setToolTipText(getBrowseText());
browse.setImage(AbstractUIPlugin.imageDescriptorFromPlugin(FrameworkUtil.getBundle(this.getClass()).getSymbolicName(), "full/etool16/browse.gif").createImage());
browse.setImage(AbstractUIPlugin.imageDescriptorFromPlugin(FrameworkUtil.getBundle(this.getClass()).getSymbolicName(), ICONS_PATH + "full/etool16/browse.gif").createImage());
browse.addSelectionListener(new SelectionListener() {

public void widgetSelected(SelectionEvent event) {
Expand All @@ -98,7 +99,7 @@ public void widgetDefaultSelected(SelectionEvent e) {
if (isDeleteButton()) {
delete = new ToolItem(toolbar, SWT.PUSH);
delete.setToolTipText("Delete all elements");
delete.setImage(AbstractUIPlugin.imageDescriptorFromPlugin(FrameworkUtil.getBundle(this.getClass()).getSymbolicName(), "full/etool16/delete_edit.gif").createImage());
delete.setImage(AbstractUIPlugin.imageDescriptorFromPlugin(FrameworkUtil.getBundle(this.getClass()).getSymbolicName(), ICONS_PATH + "full/etool16/delete_edit.gif").createImage());
delete.addSelectionListener(new SelectionListener() {

public void widgetSelected(SelectionEvent event) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,11 @@ protected boolean isImage() {
@Override
protected void initializeControls(final Composite parent, IRendererContext context) {

if (isCopyButton()) {
if (isCopyButton()) {
final String ICONS_PATH = "icons/"; //$NON-NLS-1$
copyButton = new Label(rootTextControl, SWT.NONE);
copyButton.setToolTipText("Copy to clipboard");
copyButton.setImage(AbstractUIPlugin.imageDescriptorFromPlugin(FrameworkUtil.getBundle(this.getClass()).getSymbolicName(), "full/etool16/copy.gif").createImage());
copyButton.setToolTipText("Copy to clipboard"); //$NON-NLS-1$
copyButton.setImage(AbstractUIPlugin.imageDescriptorFromPlugin(FrameworkUtil.getBundle(this.getClass()).getSymbolicName(), ICONS_PATH + "full/etool16/copy.gif").createImage()); //$NON-NLS-1$
copyButton.addMouseListener(new MouseListener() {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,18 @@ public class StatusLabelHelper {
*/
public static void updateImage(IStatus status, Label label) {
if (!label.isDisposed() && status != null) {
final String ICONS_PATH = "icons/"; //$NON-NLS-1$
if (status.isOK()) {
label.setImage(AbstractUIPlugin.imageDescriptorFromPlugin(FrameworkUtil.getBundle(StatusLabelHelper.class).getSymbolicName(), "full/etool16/empty.gif").createImage());
label.setImage(AbstractUIPlugin.imageDescriptorFromPlugin(FrameworkUtil.getBundle(StatusLabelHelper.class).getSymbolicName(), ICONS_PATH + "full/etool16/empty.gif").createImage());

} else if (status.matches(IStatus.INFO)) {
label.setImage(AbstractUIPlugin.imageDescriptorFromPlugin(FrameworkUtil.getBundle(StatusLabelHelper.class).getSymbolicName(), "full/etool16/info_tsk.gif").createImage());
label.setImage(AbstractUIPlugin.imageDescriptorFromPlugin(FrameworkUtil.getBundle(StatusLabelHelper.class).getSymbolicName(), ICONS_PATH + "full/etool16/info_tsk.gif").createImage());

} else if (status.matches(IStatus.WARNING)) {
label.setImage(AbstractUIPlugin.imageDescriptorFromPlugin(FrameworkUtil.getBundle(StatusLabelHelper.class).getSymbolicName(), "full/etool16/warn_tsk.gif").createImage());
label.setImage(AbstractUIPlugin.imageDescriptorFromPlugin(FrameworkUtil.getBundle(StatusLabelHelper.class).getSymbolicName(), ICONS_PATH + "full/etool16/warn_tsk.gif").createImage());

} else if (status.matches(IStatus.ERROR)) {
label.setImage(AbstractUIPlugin.imageDescriptorFromPlugin(FrameworkUtil.getBundle(StatusLabelHelper.class).getSymbolicName(), "full/etool16/error_tsk.gif").createImage());
label.setImage(AbstractUIPlugin.imageDescriptorFromPlugin(FrameworkUtil.getBundle(StatusLabelHelper.class).getSymbolicName(), ICONS_PATH + "full/etool16/error_tsk.gif").createImage());
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@ Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.polarsys.capella.common.platform.eclipse.tools.report.ui;singleton:=true
Bundle-Version: 6.0.0.qualifier
Bundle-Activator: org.polarsys.capella.common.platform.eclipse.tools.report.ui.ReportManagerUI
Bundle-Vendor: %providerName
Require-Bundle: org.polarsys.capella.common.tools.report.ui,
org.eclipse.ui,
org.eclipse.core.runtime
Bundle-ActivationPolicy: lazy
Export-Package: org.polarsys.capella.common.platform.eclipse.tools.report.ui,
org.polarsys.capella.common.platform.eclipse.tools.report.ui.pref
Export-Package: org.polarsys.capella.common.platform.eclipse.tools.report.ui.pref
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-Localization: plugin

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ protected static String getCustomText(Object object, int columnIndex) {
@Override
@SuppressWarnings("synthetic-access")
protected void createCustomActions(Composite parent) {

_timeEventBtn = createTableButton(parent, AbstractUIPlugin.imageDescriptorFromPlugin(FrameworkUtil.getBundle(this.getClass()).getSymbolicName(), IImageKeys.TIME_EVENT_IMG_16).createImage(),
final String ICONS_PATH = "icons/"; //$NON-NLS-1$
_timeEventBtn = createTableButton(parent, AbstractUIPlugin.imageDescriptorFromPlugin(FrameworkUtil.getBundle(this.getClass()).getSymbolicName(), ICONS_PATH + IImageKeys.TIME_EVENT_IMG_16).createImage(),
new Runnable() {
@Override
public void run() {
Expand All @@ -122,7 +122,7 @@ public void run() {
});
_timeEventBtn.setToolTipText("Create a Time Event");

_changeEventBtn = createTableButton(parent, AbstractUIPlugin.imageDescriptorFromPlugin(FrameworkUtil.getBundle(this.getClass()).getSymbolicName(), IImageKeys.CHANGE_EVENT_IMG_16).createImage(),
_changeEventBtn = createTableButton(parent, AbstractUIPlugin.imageDescriptorFromPlugin(FrameworkUtil.getBundle(this.getClass()).getSymbolicName(), ICONS_PATH + IImageKeys.CHANGE_EVENT_IMG_16).createImage(),
new Runnable() {
@Override
public void run() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ public class MetricAction extends BaseSelectionListenerAction {

public MetricAction() {
super(MetricMessages.metricAction_lbl);
setImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin(FrameworkUtil.getBundle(this.getClass()).getSymbolicName(), IImageKeys.IMG_METRICS));
final String ICONS_PATH = "icons/";
setImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin(FrameworkUtil.getBundle(this.getClass()).getSymbolicName(), ICONS_PATH + IImageKeys.IMG_METRICS));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ public class ProgressMonitoringOverviewAction extends BaseSelectionListenerActio
*/
public ProgressMonitoringOverviewAction() {
super(MetricMessages.progressMonitoring_overviewAction_lbl);
setImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin(FrameworkUtil.getBundle(this.getClass()).getSymbolicName(), IImageKeys.IMG_METRICS));
final String ICONS_PATH = "icons/";
setImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin(FrameworkUtil.getBundle(this.getClass()).getSymbolicName(), ICONS_PATH + IImageKeys.IMG_METRICS));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ public class ProgressMonitoringSetAction extends BaseSelectionListenerAction {
*/
public ProgressMonitoringSetAction() {
super(MetricMessages.progressMonitoring_setAction_lbl);
setImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin(FrameworkUtil.getBundle(this.getClass()).getSymbolicName(), IImageKeys.IMG_PROGRESS_MONITORING));
final String ICONS_PATH = "icons/";
setImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin(FrameworkUtil.getBundle(this.getClass()).getSymbolicName(), ICONS_PATH + IImageKeys.IMG_PROGRESS_MONITORING));
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,22 +49,22 @@ public String getText(Object object) {
@Override
public Image getImage(Object object) {
if (object instanceof IFile) {
return AbstractUIPlugin.imageDescriptorFromPlugin(FrameworkUtil.getBundle(this.getClass()).getSymbolicName(), "full/obj16/test.png").createImage();
return AbstractUIPlugin.imageDescriptorFromPlugin(FrameworkUtil.getBundle(this.getClass()).getSymbolicName(), "icons/full/obj16/test.png").createImage();
}
if (object instanceof QueryResult) {
if (((QueryResult) object).getBusinessQuery() == null) {
return AbstractUIPlugin.imageDescriptorFromPlugin(FrameworkUtil.getBundle(this.getClass()).getSymbolicName(), "full/obj16/error_tsk.png").createImage();
return AbstractUIPlugin.imageDescriptorFromPlugin(FrameworkUtil.getBundle(this.getClass()).getSymbolicName(), "icons/full/obj16/error_tsk.png").createImage();
}
EObject adapt = Adapters.adapt(object, Element.class);
if (adapt != null) {
return super.getImage(adapt);
}
} else if (object instanceof ResultItem) {
if (((ResultItem)object).getKind() == Kind.ADDED) {
return AbstractUIPlugin.imageDescriptorFromPlugin(FrameworkUtil.getBundle(this.getClass()).getSymbolicName(), "full/obj16/add_obj.png").createImage();
return AbstractUIPlugin.imageDescriptorFromPlugin(FrameworkUtil.getBundle(this.getClass()).getSymbolicName(), "icons/full/obj16/add_obj.png").createImage();
}
if (((ResultItem)object).getKind() == Kind.MISSING) {
return AbstractUIPlugin.imageDescriptorFromPlugin(FrameworkUtil.getBundle(this.getClass()).getSymbolicName(), "full/obj16/delete_edit.png").createImage();
return AbstractUIPlugin.imageDescriptorFromPlugin(FrameworkUtil.getBundle(this.getClass()).getSymbolicName(), "icons/full/obj16/delete_edit.png").createImage();
}
EObject adapt = Adapters.adapt(object, Element.class);
if (adapt != null) {
Expand Down

0 comments on commit 9f9724c

Please sign in to comment.