Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion bundles/io.openliberty.tools.eclipse.ui/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ Require-Bundle: org.eclipse.ui,
org.eclipse.m2e.maven.runtime,
org.eclipse.jdt.debug.ui;bundle-version="3.14.0",
org.eclipse.jdt.debug;bundle-version="3.22.0",
org.eclipse.ui.ide
org.eclipse.ui.ide,
org.eclipse.ui.navigator,
org.eclipse.e4.ui.model.workbench
Bundle-RequiredExecutionEnvironment: JavaSE-21
Automatic-Module-Name: io.openliberty.tools.eclipse.ui
Bundle-ActivationPolicy: lazy
Expand All @@ -36,6 +38,7 @@ Import-Package: org.eclipse.buildship.core,
org.eclipse.debug.ui,
org.eclipse.debug.ui.actions,
org.eclipse.debug.ui.sourcelookup,
org.eclipse.e4.core.di.annotations,
org.eclipse.jdi,
org.eclipse.jdt.core,
org.eclipse.jdt.debug.core,
Expand Down
17 changes: 16 additions & 1 deletion bundles/io.openliberty.tools.eclipse.ui/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -775,7 +775,7 @@
</wizard>
</extension>

<!-- Add Liberty Starter to Java perspective shortcuts -->
<!-- Add Liberty Starter wizard shortcut to Java/Jakarta EE/resource perspectives -->
<extension point="org.eclipse.ui.perspectiveExtensions">
<perspectiveExtension targetID="org.eclipse.jdt.ui.JavaPerspective">
<newWizardShortcut id="io.openliberty.tools.eclipse.ui.wizard.LibertyStarter"/>
Expand All @@ -786,5 +786,20 @@
<perspectiveExtension targetID="org.eclipse.jdt.ui.JavaBrowsingPerspective">
<newWizardShortcut id="io.openliberty.tools.eclipse.ui.wizard.LibertyStarter"/>
</perspectiveExtension>
<perspectiveExtension targetID="org.eclipse.jst.j2ee.J2EEPerspective">
<newWizardShortcut id="io.openliberty.tools.eclipse.ui.wizard.LibertyStarter"/>
</perspectiveExtension>
</extension>


<!-- E4 model processor: adds Liberty wizard shortcut tag to all perspectives
on every startup so the empty Project/Package Explorer link always appears -->
<extension id="io.openliberty.tools.eclipse.ui.model.processor"
point="org.eclipse.e4.workbench.model">
<processor
apply="always"
beforefragment="false"
class="io.openliberty.tools.eclipse.ui.model.LibertyPerspectiveProcessor">
</processor>
</extension>
</plugin>
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ public static LibertyDevPlugin getDefault() {
* Register listeners.
*/
private void registerListeners() {
if (!PlatformUI.isWorkbenchRunning()) {
return;
}
PlatformUI.getWorkbench().getDisplay().asyncExec(() -> {
registerResourceChangeListener();
});
Expand Down Expand Up @@ -139,6 +142,10 @@ private void registerResourceChangeListener() {
* Removes the resource change listener registered with the Eclipse workspace.
*/
public void unregisterResourceChangeListener() {
if (resourceChangeListener == null) {
return;
}

if (Trace.isEnabled()) {
Trace.getTracer().traceEntry(Trace.TRACE_TOOLS, resourceChangeListener);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*******************************************************************************
* Copyright (c) 2025 IBM Corporation and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* IBM Corporation - initial implementation
*******************************************************************************/
package io.openliberty.tools.eclipse.ui.model;

import java.util.List;

import org.eclipse.e4.core.di.annotations.Execute;
import org.eclipse.e4.ui.model.application.MApplication;
import org.eclipse.e4.ui.model.application.ui.MElementContainer;
import org.eclipse.e4.ui.model.application.ui.MUIElement;
import org.eclipse.e4.ui.model.application.ui.advanced.MPerspective;

/**
* E4 model processor registered via org.eclipse.e4.workbench.model extension
* point. Runs synchronously on every startup during model assembly. Recursively
* walks the entire model tree to find every MPerspective and adds the Liberty
* Starter wizard shortcut tag so the "Create new Liberty starter project" link
* appears in the empty Project/Package Explorer without a perspective reset.
*/
public class LibertyPerspectiveProcessor {

private static final String LIBERTY_WIZARD_TAG =
"persp.newWizSC:io.openliberty.tools.eclipse.ui.wizard.LibertyStarter"; //$NON-NLS-1$

@Execute
public void process(MApplication application) {
// Recursively walk the entire model tree — perspectives can be nested
// at any depth (e.g. TrimmedWindow → PartSashContainer → PerspectiveStack → Perspective)
walkAndTag(application);
}

private void walkAndTag(MUIElement element) {
if (element instanceof MPerspective perspective) {
addTagIfMissing(perspective);
}
if (element instanceof MElementContainer<?> container) {
for (Object child : container.getChildren()) {
if (child instanceof MUIElement childEl) {
walkAndTag(childEl);
}
}
}
}

private void addTagIfMissing(MPerspective perspective) {
List<String> tags = perspective.getTags();
if (!tags.contains(LIBERTY_WIZARD_TAG)) {
tags.add(LIBERTY_WIZARD_TAG);
}
}
}
Loading