Skip to content

Commit edd8a07

Browse files
authored
Merge pull request #2753 from akurtakov/develop
Minor optimizations
2 parents 7da8595 + 6c124d0 commit edd8a07

File tree

9 files changed

+52
-67
lines changed

9 files changed

+52
-67
lines changed

chemclipse/plugins/org.eclipse.chemclipse.rcp.app.ui/src/org/eclipse/chemclipse/rcp/app/ui/dialogs/PerspectiveSwitcherDialog.java

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,23 @@
11
/*******************************************************************************
2-
* Copyright (c) 2012, 2025 Lablicate GmbH.
2+
* Copyright (c) 2012, 2026 Lablicate GmbH.
33
*
44
* This program and the accompanying materials are made
55
* available under the terms of the Eclipse Public License 2.0
66
* which is available at https://www.eclipse.org/legal/epl-2.0/
77
*
88
* SPDX-License-Identifier: EPL-2.0
9-
*
9+
*
1010
* Contributors:
1111
* Philip Wenig - initial API and implementation
1212
*******************************************************************************/
1313
package org.eclipse.chemclipse.rcp.app.ui.dialogs;
1414

1515
import java.util.ArrayList;
1616
import java.util.Collections;
17+
import java.util.Comparator;
1718
import java.util.List;
1819
import java.util.concurrent.atomic.AtomicReference;
1920

20-
import jakarta.inject.Inject;
21-
import jakarta.inject.Named;
22-
2321
import org.eclipse.chemclipse.rcp.app.ui.provider.PerspectiveSwitcherContentProvider;
2422
import org.eclipse.chemclipse.rcp.app.ui.provider.PerspectiveSwitcherLabelProvider;
2523
import org.eclipse.chemclipse.rcp.app.ui.provider.PerspectiveSwitcherViewerFilter;
@@ -55,6 +53,9 @@
5553
import org.eclipse.swt.widgets.TableItem;
5654
import org.eclipse.swt.widgets.Text;
5755

56+
import jakarta.inject.Inject;
57+
import jakarta.inject.Named;
58+
5859
public class PerspectiveSwitcherDialog extends Dialog implements ISelectionChangedListener {
5960

6061
/*
@@ -98,6 +99,7 @@ public PerspectiveSwitcherDialog(@Named(IServiceConstants.ACTIVE_SHELL) Shell sh
9899
setShellStyle(getShellStyle() | SWT.SHEET);
99100
}
100101

102+
@Override
101103
protected void configureShell(Shell shell) {
102104

103105
super.configureShell(shell);
@@ -122,11 +124,12 @@ public void selectionChanged(SelectionChangedEvent event) {
122124
/**
123125
* Creates and returns the contents of the upper part of this dialog (above
124126
* the button bar).
125-
*
127+
*
126128
* @param parent
127129
* the parent composite to contain the dialog area
128130
* @return the dialog area control
129131
*/
132+
@Override
130133
protected Control createDialogArea(Composite parent) {
131134

132135
Composite composite = (Composite)super.createDialogArea(parent);
@@ -145,10 +148,7 @@ protected Control createDialogArea(Composite parent) {
145148
return composite;
146149
}
147150

148-
/*
149-
* (non-Javadoc)
150-
* @see org.eclipse.jface.dialogs.Dialog#okPressed()
151-
*/
151+
@Override
152152
protected void okPressed() {
153153

154154
super.okPressed();
@@ -157,8 +157,8 @@ protected void okPressed() {
157157

158158
private void initialize() {
159159

160-
perspectives.addAll(modelService.findElements(application, null, MPerspective.class, null));
161-
Collections.sort(perspectives, (p1, p2) -> p1.getLabel().compareTo(p2.getLabel()));
160+
perspectives.addAll(modelService.findElements(application, null, MPerspective.class));
161+
Collections.sort(perspectives, Comparator.comparing(MPerspective::getLabel));
162162
perspectiveSwitcherViewerFilter.setCaseInsensitive(true);
163163
}
164164

@@ -177,8 +177,6 @@ private void switchPerspective() {
177177

178178
/**
179179
* Creates a text field to search the list of perspectives.
180-
*
181-
* @param parent
182180
*/
183181
private void createPerspectivesSearchTextField(Composite parent) {
184182

@@ -213,8 +211,6 @@ public void mouseUp(MouseEvent e) {
213211

214212
/**
215213
* Creates the list of available perspectives.
216-
*
217-
* @param parent
218214
*/
219215
private void createPerspectivesList(Composite parent) {
220216

chemclipse/plugins/org.eclipse.chemclipse.rcp.app.ui/src/org/eclipse/chemclipse/rcp/app/ui/dialogs/SelectViewDialog.java

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,19 @@
11
/*******************************************************************************
2-
* Copyright (c) 2012, 2025 Lablicate GmbH.
2+
* Copyright (c) 2012, 2026 Lablicate GmbH.
33
*
44
* This program and the accompanying materials are made
55
* available under the terms of the Eclipse Public License 2.0
66
* which is available at https://www.eclipse.org/legal/epl-2.0/
77
*
88
* SPDX-License-Identifier: EPL-2.0
9-
*
9+
*
1010
* Contributors:
1111
* Philip Wenig - initial API and implementation
1212
*******************************************************************************/
1313
package org.eclipse.chemclipse.rcp.app.ui.dialogs;
1414

1515
import java.util.List;
1616

17-
import jakarta.inject.Inject;
18-
import jakarta.inject.Named;
19-
2017
import org.eclipse.chemclipse.rcp.app.ui.provider.SelectViewContentProvider;
2118
import org.eclipse.chemclipse.rcp.app.ui.provider.SelectViewFilter;
2219
import org.eclipse.chemclipse.rcp.app.ui.provider.SelectViewLabelProvider;
@@ -48,6 +45,9 @@
4845
import org.eclipse.swt.widgets.TableItem;
4946
import org.eclipse.swt.widgets.Text;
5047

48+
import jakarta.inject.Inject;
49+
import jakarta.inject.Named;
50+
5151
public class SelectViewDialog extends Dialog implements ISelectionChangedListener {
5252

5353
/*
@@ -72,9 +72,6 @@ public class SelectViewDialog extends Dialog implements ISelectionChangedListene
7272
private EModelService modelService;
7373
@Inject
7474
private EPartService partService;
75-
/*
76-
*
77-
*/
7875
private List<MPart> parts;
7976
private MPart selectedPart;
8077

@@ -85,15 +82,12 @@ public SelectViewDialog(@Named(IServiceConstants.ACTIVE_SHELL) Shell shell) {
8582
setShellStyle(getShellStyle() | SWT.SHEET);
8683
}
8784

88-
/*
89-
* (non-Javadoc)
90-
* @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
91-
*/
85+
@Override
9286
protected void configureShell(Shell shell) {
9387

9488
super.configureShell(shell);
9589
shell.setText("Select View");
96-
parts = modelService.findElements(application, null, MPart.class, null);
90+
parts = modelService.findElements(application, null, MPart.class);
9791
}
9892

9993
@Override
@@ -116,11 +110,12 @@ public void selectionChanged(SelectionChangedEvent event) {
116110
/**
117111
* Creates and returns the contents of the upper part of this dialog (above
118112
* the button bar).
119-
*
113+
*
120114
* @param parent
121115
* the parent composite to contain the dialog area
122116
* @return the dialog area control
123117
*/
118+
@Override
124119
protected Control createDialogArea(Composite parent) {
125120

126121
Composite composite = (Composite)super.createDialogArea(parent);
@@ -139,10 +134,7 @@ protected Control createDialogArea(Composite parent) {
139134
return composite;
140135
}
141136

142-
/*
143-
* (non-Javadoc)
144-
* @see org.eclipse.jface.dialogs.Dialog#okPressed()
145-
*/
137+
@Override
146138
protected void okPressed() {
147139

148140
super.okPressed();
@@ -164,7 +156,7 @@ private void selectAndActivatePart() {
164156

165157
/**
166158
* Creates a text field to search the list of perspectives.
167-
*
159+
*
168160
* @param parent
169161
*/
170162
private void createViewSearchTextField(Composite parent) {
@@ -196,7 +188,7 @@ public void mouseUp(MouseEvent e) {
196188

197189
/**
198190
* Creates the list of available perspectives.
199-
*
191+
*
200192
* @param parent
201193
*/
202194
private void createViewList(Composite parent) {

chemclipse/plugins/org.eclipse.chemclipse.rcp.app.ui/src/org/eclipse/chemclipse/rcp/app/ui/switcher/PerspectiveSwitcher.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,19 @@
11
/*******************************************************************************
2-
* Copyright (c) 2013, 2025 Lablicate GmbH.
2+
* Copyright (c) 2013, 2026 Lablicate GmbH.
33
*
44
* This program and the accompanying materials are made
55
* available under the terms of the Eclipse Public License 2.0
66
* which is available at https://www.eclipse.org/legal/epl-2.0/
77
*
88
* SPDX-License-Identifier: EPL-2.0
9-
*
9+
*
1010
* Contributors:
1111
* Philip Wenig - initial API and implementation
1212
*******************************************************************************/
1313
package org.eclipse.chemclipse.rcp.app.ui.switcher;
1414

1515
import java.util.List;
1616

17-
import jakarta.inject.Inject;
18-
1917
import org.eclipse.chemclipse.support.events.IChemClipseEvents;
2018
import org.eclipse.e4.core.services.events.IEventBroker;
2119
import org.eclipse.e4.ui.model.application.MApplication;
@@ -26,6 +24,8 @@
2624
import org.eclipse.e4.ui.workbench.modeling.EPartService;
2725
import org.eclipse.e4.ui.workbench.modeling.EPartService.PartState;
2826

27+
import jakarta.inject.Inject;
28+
2929
public class PerspectiveSwitcher {
3030

3131
/*
@@ -42,12 +42,12 @@ public class PerspectiveSwitcher {
4242

4343
/**
4444
* Try to load the perspective.
45-
*
45+
*
4646
* @param perspectiveId
4747
*/
4848
public void changePerspective(String perspectiveId) {
4949

50-
List<MPerspective> perspectives = modelService.findElements(application, null, MPerspective.class, null);
50+
List<MPerspective> perspectives = modelService.findElements(application, null, MPerspective.class);
5151
for(MPerspective mPerspective : perspectives) {
5252
String elementId = mPerspective.getElementId();
5353
String elementLabel = mPerspective.getLabel();
@@ -63,7 +63,7 @@ public void changePerspective(String perspectiveId) {
6363

6464
/**
6565
* Load and show the view.
66-
*
66+
*
6767
* @param viewId
6868
*/
6969
public void focusView(String viewId) {

chemclipse/plugins/org.eclipse.chemclipse.support.ui/src/org/eclipse/chemclipse/support/ui/workbench/PerspectiveSupport.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,14 @@
66
* which is available at https://www.eclipse.org/legal/epl-2.0/
77
*
88
* SPDX-License-Identifier: EPL-2.0
9-
*
9+
*
1010
* Contributors:
1111
* Christoph Läubrich - initial API and implementation
1212
*******************************************************************************/
1313
package org.eclipse.chemclipse.support.ui.workbench;
1414

1515
import java.util.List;
1616

17-
import jakarta.inject.Inject;
18-
1917
import org.eclipse.chemclipse.support.events.IChemClipseEvents;
2018
import org.eclipse.e4.core.di.annotations.Creatable;
2119
import org.eclipse.e4.core.services.events.IEventBroker;
@@ -25,9 +23,11 @@
2523
import org.eclipse.e4.ui.workbench.modeling.EModelService;
2624
import org.eclipse.e4.ui.workbench.modeling.EPartService;
2725

26+
import jakarta.inject.Inject;
27+
2828
/**
2929
* A helper class that can be injected into E4 parts to perform common tasks related to perspectives
30-
*
30+
*
3131
* @author Christoph Läubrich
3232
*
3333
*/
@@ -68,7 +68,7 @@ public String getActivePerspective() {
6868

6969
private MPerspective getActiveMPerspective() {
7070

71-
List<MPerspectiveStack> perspectiveStacks = eModelService.findElements(mApplication, null, MPerspectiveStack.class, null);
71+
List<MPerspectiveStack> perspectiveStacks = eModelService.findElements(mApplication, null, MPerspectiveStack.class);
7272
if(!perspectiveStacks.isEmpty()) {
7373
MPerspectiveStack perspectiveStack = perspectiveStacks.get(0);
7474
return perspectiveStack.getSelectedElement();
@@ -78,7 +78,7 @@ private MPerspective getActiveMPerspective() {
7878

7979
/**
8080
* Try to load the perspective.
81-
*
81+
*
8282
* @param perspectiveId
8383
*/
8484
public void changePerspective(String perspectiveId) {
@@ -97,7 +97,7 @@ public void changePerspective(String perspectiveId) {
9797
public MPerspective getPerspectiveModel(String perspectiveId) {
9898

9999
if(perspectiveId != null) {
100-
List<MPerspective> elements = eModelService.findElements(mApplication, null, MPerspective.class, null);
100+
List<MPerspective> elements = eModelService.findElements(mApplication, perspectiveId, MPerspective.class);
101101
if(elements != null && !elements.isEmpty()) {
102102
for(MPerspective perspective : elements) {
103103
String elementId = perspective.getElementId();

chemclipse/plugins/org.eclipse.chemclipse.ux.extension.ui/src/org/eclipse/chemclipse/ux/extension/ui/provider/ISupplierFileEditorSupport.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ default void openEditor(File file, Object object, String elementId, String contr
9898
if(file != null) {
9999
boolean sourceIsDirectory = file.isDirectory();
100100
if(!PreferenceSupplierDataExplorer.isOpenEditorMultipleTimes()) {
101-
List<MPart> parts = modelService.findElements(application, null, MPart.class, null);
101+
List<MPart> parts = modelService.findElements(application, null, MPart.class);
102102
if(parts != null) {
103103
exitloop:
104104
for(MPart part : parts) {

chemclipse/plugins/org.eclipse.chemclipse.ux.extension.ui/src/org/eclipse/chemclipse/ux/extension/ui/swt/ProcessMethodToolbar.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* which is available at https://www.eclipse.org/legal/epl-2.0/
77
*
88
* SPDX-License-Identifier: EPL-2.0
9-
*
9+
*
1010
* Contributors:
1111
* Philip Wenig - initial API and implementation
1212
* Christoph Läubrich - make UI configurable, support selection of existing process methods, support for init with different datatypes
@@ -238,7 +238,7 @@ public boolean modifyProcessEntry(Shell shell, IProcessEntry processEntry, IProc
238238
/**
239239
* Delete the selected entries.
240240
* A message dialog is shown before deleting the entries.
241-
*
241+
*
242242
* @param shell
243243
*/
244244
public void deleteSelectedProcessEntries(Shell shell) {
@@ -310,8 +310,7 @@ private ToolItem createAddButton(ToolBar toolBar) {
310310
item.addListener(SWT.Selection, event -> {
311311
if(event.detail == SWT.ARROW) {
312312
Rectangle rectangle = item.getBounds();
313-
Point point = new Point(rectangle.x, rectangle.y + rectangle.height);
314-
point = toolBar.toDisplay(point);
313+
Point point = toolBar.toDisplay(rectangle.x, rectangle.y + rectangle.height);
315314

316315
for(MenuItem menuItem : menu.getItems()) {
317316
menuItem.dispose();

chemclipse/plugins/org.eclipse.chemclipse.ux.extension.xxd.ui/src/org/eclipse/chemclipse/ux/extension/xxd/ui/part/support/EditorUpdateSupport.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
/*******************************************************************************
2-
* Copyright (c) 2017, 2025 Lablicate GmbH.
2+
* Copyright (c) 2017, 2026 Lablicate GmbH.
33
*
44
* This program and the accompanying materials are made
55
* available under the terms of the Eclipse Public License 2.0
66
* which is available at https://www.eclipse.org/legal/epl-2.0/
77
*
88
* SPDX-License-Identifier: EPL-2.0
9-
*
9+
*
1010
* Contributors:
1111
* Philip Wenig - initial API and implementation
1212
* Christoph Läubrich - Fix method for NMR
@@ -228,7 +228,7 @@ private List<IChromatogramSelection> getChromatogramSelectionsByApplication() {
228228
if(application != null) {
229229
EModelService service = Activator.getDefault().getModelService();
230230
if(service != null) {
231-
List<MPart> parts = service.findElements(application, null, MPart.class, null);
231+
List<MPart> parts = service.findElements(application, null, MPart.class);
232232
if(parts != null) {
233233
for(MPart part : parts) {
234234
if(!extractChromatogramSelections(part.getObject()).isEmpty()) {

0 commit comments

Comments
 (0)