-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adapt template classes to PDE codebase
- Loading branch information
Showing
24 changed files
with
563 additions
and
378 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,7 @@ | |
* Neil Bartlett <[email protected]> - initial API and implementation | ||
* BJ Hargrave <[email protected]> - ongoing enhancements | ||
*******************************************************************************/ | ||
package org.bndtools.utils.swt; | ||
package org.eclipse.pde.bnd.ui; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,7 @@ | |
* Neil Bartlett <[email protected]> - initial API and implementation | ||
* BJ Hargrave <[email protected]> - ongoing enhancements | ||
*******************************************************************************/ | ||
package org.bndtools.utils.jface; | ||
package org.eclipse.pde.bnd.ui; | ||
|
||
import org.eclipse.jface.preference.JFacePreferences; | ||
import org.eclipse.jface.resource.ColorRegistry; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,7 @@ | |
* Neil Bartlett <[email protected]> - initial API and implementation | ||
* BJ Hargrave <[email protected]> - ongoing enhancements | ||
*******************************************************************************/ | ||
package bndtools.shared; | ||
package org.eclipse.pde.bnd.ui; | ||
|
||
import org.eclipse.jface.viewers.StyledString; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,7 @@ | |
* Neil Bartlett <[email protected]> - ongoing enhancements | ||
* BJ Hargrave <[email protected]> - ongoing enhancements | ||
*******************************************************************************/ | ||
package bndtools.shared; | ||
package org.eclipse.pde.bnd.ui; | ||
|
||
import java.io.File; | ||
import java.net.URI; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2010, 2021 bndtools project and others. | ||
* Copyright (c) 2010, 2023 bndtools project and others. | ||
* | ||
* This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License 2.0 | ||
|
@@ -12,22 +12,19 @@ | |
* Neil Bartlett <[email protected]> - initial API and implementation | ||
* BJ Hargrave <[email protected]> - ongoing enhancements | ||
* Peter Kriens <[email protected]> - ongoing enhancements | ||
* Christoph Läubrich - adapt to PDE code base | ||
*******************************************************************************/ | ||
package bndtools.shared; | ||
package org.eclipse.pde.bnd.ui; | ||
|
||
import org.bndtools.core.ui.icons.Icons; | ||
import org.eclipse.jface.viewers.StyledCellLabelProvider; | ||
import org.eclipse.jface.viewers.StyledString; | ||
import org.eclipse.jface.viewers.ViewerCell; | ||
import org.eclipse.swt.graphics.Device; | ||
import org.eclipse.swt.graphics.Image; | ||
|
||
public class URLLabelProvider extends StyledCellLabelProvider { | ||
|
||
private final static Image linkImg = Icons.image("link"); | ||
private final static Image fileImg = Icons.image("file"); | ||
|
||
public URLLabelProvider(Device display) {} | ||
private final static Image linkImg = Resources.getImage("/icons/link.png"); | ||
private final static Image fileImg = Resources.getImage("/icon/file.png"); | ||
|
||
@Override | ||
public void update(ViewerCell cell) { | ||
|
33 changes: 33 additions & 0 deletions
33
ui/org.eclipse.pde.bnd.ui/src/org/eclipse/pde/bnd/ui/preferences/ReposPreference.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2023 Christoph Läubrich and others. | ||
* | ||
* This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License 2.0 | ||
* which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Christoph Läubrich - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.pde.bnd.ui.preferences; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
import java.util.function.Function; | ||
|
||
public interface ReposPreference { | ||
|
||
public static final String KEY_TEMPLATE_REPO_URI_LIST = "templateRepoUriList"; | ||
|
||
public static final boolean DEF_ENABLE_TEMPLATE_REPOSITORIES = false; | ||
|
||
public static final String KEY_ENABLE_TEMPLATE_REPOSITORIES = "enableTemplateRepositories"; | ||
|
||
public static final String TEMPLATE_LOADER_NODE = "repoTemplateLoader"; | ||
|
||
public static final Function<String, List<String>> TEMPLATE_REPOSITORIES_PARSER = s -> s == null || s.isBlank() | ||
? List.of() | ||
: Arrays.asList(s.split("\\s")); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2015, 2019 bndtools project and others. | ||
* Copyright (c) 2015, 2023 bndtools project and others. | ||
* | ||
* This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License 2.0 | ||
|
@@ -12,22 +12,28 @@ | |
* Neil Bartlett <[email protected]> - initial API and implementation | ||
* Sean Bright <[email protected]> - ongoing enhancements | ||
* BJ Hargrave <[email protected]> - ongoing enhancements | ||
* Christoph Läubrich - adapt to PDE code base | ||
*******************************************************************************/ | ||
package bndtools.preferences.ui; | ||
package org.eclipse.pde.bnd.ui.preferences; | ||
|
||
import java.net.URI; | ||
import java.net.URISyntaxException; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
import org.bndtools.utils.swt.AddRemoveButtonBarPart; | ||
import org.bndtools.utils.swt.AddRemoveButtonBarPart.AddRemoveListener; | ||
import org.eclipse.core.runtime.preferences.IEclipsePreferences; | ||
import org.eclipse.core.runtime.preferences.InstanceScope; | ||
import org.eclipse.jface.fieldassist.ControlDecoration; | ||
import org.eclipse.jface.fieldassist.FieldDecorationRegistry; | ||
import org.eclipse.jface.preference.PreferencePage; | ||
import org.eclipse.jface.viewers.ArrayContentProvider; | ||
import org.eclipse.jface.viewers.TableViewer; | ||
import org.eclipse.jface.window.Window; | ||
import org.eclipse.pde.bnd.ui.AddRemoveButtonBarPart; | ||
import org.eclipse.pde.bnd.ui.AddRemoveButtonBarPart.AddRemoveListener; | ||
import org.eclipse.pde.bnd.ui.URLDialog; | ||
import org.eclipse.pde.bnd.ui.URLLabelProvider; | ||
import org.eclipse.swt.SWT; | ||
import org.eclipse.swt.events.KeyAdapter; | ||
import org.eclipse.swt.events.KeyEvent; | ||
|
@@ -43,23 +49,26 @@ | |
import org.eclipse.swt.widgets.Table; | ||
import org.eclipse.ui.IWorkbench; | ||
import org.eclipse.ui.IWorkbenchPreferencePage; | ||
import org.osgi.framework.FrameworkUtil; | ||
import org.osgi.service.prefs.BackingStoreException; | ||
|
||
import bndtools.preferences.BndPreferences; | ||
import bndtools.shared.URLDialog; | ||
import bndtools.shared.URLLabelProvider; | ||
|
||
public class ReposPreferencePage extends PreferencePage implements IWorkbenchPreferencePage { | ||
public class ReposPreferencePage extends PreferencePage implements IWorkbenchPreferencePage, ReposPreference { | ||
|
||
private static final String REPO_DEFAULT = "https://raw.githubusercontent.com/bndtools/bundle-hub/master/index.xml.gz"; | ||
private boolean enableTemplateRepo; | ||
private List<String> templateRepos; | ||
private TableViewer vwrRepos; | ||
private IEclipsePreferences preferences; | ||
|
||
@Override | ||
public void init(IWorkbench workbench) { | ||
BndPreferences prefs = new BndPreferences(); | ||
|
||
enableTemplateRepo = prefs.getEnableTemplateRepo(); | ||
templateRepos = new ArrayList<>(prefs.getTemplateRepoUriList()); | ||
preferences = (IEclipsePreferences) InstanceScope.INSTANCE | ||
.getNode(FrameworkUtil.getBundle(ReposPreferencePage.class).getSymbolicName()) | ||
.node(TEMPLATE_LOADER_NODE); | ||
enableTemplateRepo = preferences.getBoolean(KEY_ENABLE_TEMPLATE_REPOSITORIES, DEF_ENABLE_TEMPLATE_REPOSITORIES); | ||
templateRepos = TEMPLATE_REPOSITORIES_PARSER.apply(preferences.get(KEY_TEMPLATE_REPO_URI_LIST, | ||
REPO_DEFAULT)); | ||
} | ||
|
||
@Override | ||
|
@@ -96,7 +105,7 @@ protected Control createContents(Composite parent) { | |
final Table tblRepos = new Table(group, SWT.BORDER | SWT.MULTI); | ||
vwrRepos = new TableViewer(tblRepos); | ||
vwrRepos.setContentProvider(ArrayContentProvider.getInstance()); | ||
vwrRepos.setLabelProvider(new URLLabelProvider(tblRepos.getDisplay())); | ||
vwrRepos.setLabelProvider(new URLLabelProvider()); | ||
vwrRepos.setInput(templateRepos); | ||
|
||
GridData gd = new GridData(SWT.FILL, SWT.CENTER, true, false); | ||
|
@@ -185,11 +194,22 @@ private void validate() { | |
|
||
@Override | ||
public boolean performOk() { | ||
BndPreferences prefs = new BndPreferences(); | ||
|
||
prefs.setEnableTemplateRepo(enableTemplateRepo); | ||
prefs.setTemplateRepoUriList(templateRepos); | ||
|
||
String repoList = templateRepos.stream().collect(Collectors.joining("\t")); | ||
if (enableTemplateRepo == DEF_ENABLE_TEMPLATE_REPOSITORIES) { | ||
preferences.remove(KEY_ENABLE_TEMPLATE_REPOSITORIES); | ||
if (REPO_DEFAULT.equals(repoList)) { | ||
preferences.remove(KEY_TEMPLATE_REPO_URI_LIST); | ||
} else { | ||
preferences.put(KEY_TEMPLATE_REPO_URI_LIST, repoList); | ||
} | ||
} else { | ||
preferences.putBoolean(KEY_ENABLE_TEMPLATE_REPOSITORIES, enableTemplateRepo); | ||
preferences.put(KEY_TEMPLATE_REPO_URI_LIST, repoList); | ||
} | ||
try { | ||
preferences.flush(); | ||
} catch (BackingStoreException e) { | ||
} | ||
return true; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,7 @@ | |
* Contributors: | ||
* Scott Lewis <[email protected]> - initial API and implementation | ||
*******************************************************************************/ | ||
package org.bndtools.core.ui.wizards.shared; | ||
package org.eclipse.pde.bnd.ui.templating; | ||
|
||
import java.net.URL; | ||
import java.nio.file.Path; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,7 @@ | |
* Neil Bartlett <[email protected]> - initial API and implementation | ||
* BJ Hargrave <[email protected]> - ongoing enhancements | ||
*******************************************************************************/ | ||
package org.bndtools.core.ui.wizards.shared; | ||
package org.eclipse.pde.bnd.ui.templating; | ||
|
||
import java.io.IOException; | ||
import java.net.URI; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,7 @@ | |
* Neil Bartlett <[email protected]> - initial API and implementation | ||
* BJ Hargrave <[email protected]> - ongoing enhancements | ||
*******************************************************************************/ | ||
package org.bndtools.core.templating.repobased; | ||
package org.eclipse.pde.bnd.ui.templating; | ||
|
||
import java.io.File; | ||
import java.net.URI; | ||
|
Oops, something went wrong.