use of io.sloeber.core.api.Json.ArduinoPackage in project arduino-eclipse-plugin by Sloeber.
the class BoardsManager method installsubsetOfLatestPlatforms.
/**
* installs a subset of the latest platforms It skips the first <fromIndex>
* platforms And stops at <toIndex> platforms. To install the 5 first latest
* platforms installsubsetOfLatestPlatforms(0,5)
*
* @param fromIndex
* the platforms at the start to skip
* @param toIndex
* the platforms after this platform are skipped
*/
public static void installsubsetOfLatestPlatforms(int fromIndex, int toIndex) {
if (!isReady()) {
Common.log(new Status(IStatus.ERROR, Const.CORE_PLUGIN_ID, BoardsManagerIsBussy, new Exception()));
return;
}
envVarsNeedUpdating = true;
int currPlatformIndex = 1;
NullProgressMonitor monitor = new NullProgressMonitor();
List<ArduinoPackage> allPackages = getPackages();
for (ArduinoPackage curPackage : allPackages) {
Collection<ArduinoPlatform> latestPlatforms = curPackage.getPlatforms();
for (ArduinoPlatform curPlatform : latestPlatforms) {
if (currPlatformIndex > fromIndex) {
install(curPlatform.getNewestVersion(), monitor);
}
if (currPlatformIndex++ > toIndex)
return;
}
}
}
use of io.sloeber.core.api.Json.ArduinoPackage in project arduino-eclipse-plugin by Sloeber.
the class Arduino method getAllmBedBoardNames.
private static List<String> getAllmBedBoardNames() {
List<String> ret = new LinkedList<>();
ArduinoPackage arduinoPkg = BoardsManager.getPackageByProvider(providerArduino);
for (ArduinoPlatform curPlatform : arduinoPkg.getPlatforms()) {
if (curPlatform.getArchitecture().equals(MBEDArchitectureName)) {
ArduinoPlatformVersion curPlatformVersion = curPlatform.getNewestInstalled();
if (curPlatformVersion != null) {
List<BoardDescription> boardDescriptions = BoardDescription.makeBoardDescriptors(curPlatformVersion.getBoardsFile());
for (BoardDescription curBoardDesc : boardDescriptions) {
ret.add(curBoardDesc.getBoardName());
}
}
}
}
return ret;
}
use of io.sloeber.core.api.Json.ArduinoPackage in project arduino-eclipse-plugin by Sloeber.
the class MCUBoard method getAllBoards.
public static List<MCUBoard> getAllBoards(String provider, MCUBoard creator) {
List<MCUBoard> ret = new LinkedList<>();
ArduinoPackage arduinoPkg = BoardsManager.getPackageByProvider(provider);
for (ArduinoPlatform curPlatform : arduinoPkg.getPlatforms()) {
ArduinoPlatformVersion curPlatformVersion = curPlatform.getNewestInstalled();
if (curPlatformVersion != null) {
List<BoardDescription> boardDescriptions = BoardDescription.makeBoardDescriptors(curPlatformVersion.getBoardsFile());
for (BoardDescription curBoardDesc : boardDescriptions) {
ret.add(creator.createMCUBoard(curBoardDesc));
}
}
}
return ret;
}
use of io.sloeber.core.api.Json.ArduinoPackage in project arduino-eclipse-plugin by Sloeber.
the class PlatformSelectionPage method createContents.
@Override
protected Control createContents(Composite parent) {
Composite control = new Composite(parent, SWT.NONE);
control.setLayout(new GridLayout());
Button btnCheckButton = new Button(control, SWT.CHECK);
btnCheckButton.setText(Messages.PlatformSelectionPage_hide_third_party_url);
btnCheckButton.setSelection(this.myHideJson);
btnCheckButton.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event event) {
PlatformSelectionPage.this.myHideJson = btnCheckButton.getSelection();
MyPreferences.setHideJson(PlatformSelectionPage.this.myHideJson);
PlatformSelectionPage.this.viewer.setInput(EMPTY_STRING);
}
});
Text desc = new Text(control, SWT.READ_ONLY);
desc.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
desc.setBackground(parent.getBackground());
desc.setText(Messages.platformSelectionTip);
PatternFilter filter = new PatternFilter() {
@Override
protected boolean isLeafMatch(final Viewer viewer1, final Object element) {
boolean isMatch = false;
if (element instanceof InstallableVersion) {
InstallableVersion ver = (InstallableVersion) element;
isMatch |= wordMatches(ver.getVersion().toString());
isMatch |= myWordMatches(ver.getPlatform());
}
if (element instanceof ArduinoPlatformPackageIndex) {
ArduinoPlatformPackageIndex indexFile = (ArduinoPlatformPackageIndex) element;
isMatch |= myWordMatches(indexFile);
}
if (element instanceof ArduinoPackage) {
ArduinoPackage pac = (ArduinoPackage) element;
isMatch |= myWordMatches(pac);
}
if (element instanceof ArduinoPlatformVersion) {
ArduinoPlatformVersion platform = (ArduinoPlatformVersion) element;
isMatch |= myWordMatches(platform);
}
return isMatch;
}
private boolean myWordMatches(ArduinoPlatformVersion arduinoPlatformVersion) {
boolean ret = wordMatches(arduinoPlatformVersion.getName());
ret |= wordMatches(arduinoPlatformVersion.getArchitecture());
ret |= wordMatches(arduinoPlatformVersion.getConcattenatedBoardNames());
ret |= myWordMatches(arduinoPlatformVersion.getParent().getParent());
return ret;
}
private boolean myWordMatches(ArduinoPackage pac) {
boolean ret = wordMatches(pac.getEmail());
ret |= wordMatches(pac.getMaintainer());
ret |= wordMatches(pac.getName());
ret |= wordMatches(pac.getWebsiteURL().toString());
ret |= wordMatches(pac.getPackageIndex().getJsonFile().toString());
return ret;
}
private boolean myWordMatches(ArduinoPlatformPackageIndex indexFile) {
return wordMatches(indexFile.getID());
}
};
this.myGuiplatformTree = new FilteredTree(control, SWT.CHECK | SWT.V_SCROLL | SWT.BORDER | SWT.FULL_SELECTION, filter, true, true) {
@Override
protected TreeViewer doCreateTreeViewer(Composite composite, int style) {
CheckboxTreeViewer viewer1 = new CheckboxTreeViewer(composite);
viewer1.setCheckStateProvider(new ICheckStateProvider() {
@Override
public boolean isChecked(Object element) {
if (element instanceof InstallableVersion) {
return ((InstallableVersion) element).mustBeInstalled();
}
if (element instanceof ArduinoPlatformPackageIndex) {
return mustBeInstalled((ArduinoPlatformPackageIndex) element);
}
if (element instanceof ArduinoPackage) {
return mustBeInstalled((ArduinoPackage) element);
}
if (element instanceof ArduinoPlatform) {
return mustBeInstalled((ArduinoPlatform) element);
}
return false;
}
@Override
public boolean isGrayed(Object element) {
if (element instanceof InstallableVersion) {
return false;
}
if (element instanceof ArduinoPlatformPackageIndex) {
return mustBeInstalled((ArduinoPlatformPackageIndex) element);
}
if (element instanceof ArduinoPackage) {
return mustBeInstalled((ArduinoPackage) element);
}
if (element instanceof ArduinoPlatform) {
return mustBeInstalled((ArduinoPlatform) element);
}
return false;
}
});
viewer1.addCheckStateListener(new ICheckStateListener() {
@Override
public void checkStateChanged(CheckStateChangedEvent event) {
Object element = event.getElement();
if (element instanceof InstallableVersion) {
InstallableVersion cur = (InstallableVersion) element;
cur.setMustBeInstalled(event.getChecked());
}
PlatformSelectionPage.this.viewer.refresh();
}
});
viewer1.setContentProvider(new ITreeContentProvider() {
@Override
public Object[] getElements(Object inputElement) {
if (PlatformSelectionPage.this.myHideJson) {
List<ArduinoPackage> packages = BoardsManager.getPackages();
Collections.sort(packages);
return packages.toArray(new Object[packages.size()]);
}
List<ArduinoPlatformPackageIndex> indexFiles = BoardsManager.getPackageIndices();
return indexFiles.toArray(new Object[indexFiles.size()]);
}
@Override
public void dispose() {
// nothing to do
}
@Override
public void inputChanged(Viewer viewer11, Object oldInput, Object newInput) {
// nothing to do
}
@Override
public Object[] getChildren(Object parentElement) {
if (parentElement instanceof ArduinoPlatformPackageIndex) {
Collection<ArduinoPackage> packages = ((ArduinoPlatformPackageIndex) parentElement).getPackages();
return packages.toArray(new Object[packages.size()]);
}
if (parentElement instanceof ArduinoPackage) {
Collection<ArduinoPlatform> platforms = ((ArduinoPackage) parentElement).getPlatforms();
ArduinoPlatform[] platformArray = platforms.toArray(new ArduinoPlatform[platforms.size()]);
Arrays.sort(platformArray);
return platformArray;
}
if (parentElement instanceof ArduinoPlatform) {
ArduinoPlatform platform = (ArduinoPlatform) parentElement;
ArduinoPackage parentPackage = platform.getParent();
ArduinoPlatformPackageIndex parentIndex = parentPackage.getPackageIndex();
return myShownPlatforms.get(parentIndex.getID()).get(parentPackage.getID()).get(platform.getID());
}
return null;
}
@Override
public Object getParent(Object element) {
return null;
}
@Override
public boolean hasChildren(Object element) {
return !(element instanceof InstallableVersion);
}
});
viewer1.setLabelProvider(new CellLabelProvider() {
@Override
public String getToolTipText(Object element) {
if (element instanceof ArduinoPlatformPackageIndex) {
return ((ArduinoPlatformPackageIndex) element).getID();
}
if (element instanceof ArduinoPackage) {
// $NON-NLS-1$
String NULL = "NULL";
ArduinoPackage pkg = (ArduinoPackage) element;
String maintainer = pkg.getMaintainer();
String email = pkg.getEmail();
String weburlString = pkg.getWebsiteURL();
if (maintainer == null)
maintainer = NULL;
if (email == null)
email = NULL;
if (weburlString == null)
weburlString = NULL;
return Messages.packageTooltip.replace(Messages.MAINTAINER, maintainer).replace(Messages.EMAIL, email).replace(Messages.URL, weburlString);
}
if (element instanceof ArduinoPlatformVersion) {
return ((ArduinoPlatformVersion) element).getConcattenatedBoardNames();
}
if (element instanceof InstallableVersion) {
return null;
}
return null;
}
@Override
public org.eclipse.swt.graphics.Point getToolTipShift(Object object) {
return new org.eclipse.swt.graphics.Point(5, 5);
}
@Override
public int getToolTipDisplayDelayTime(Object object) {
return 1000;
}
@Override
public int getToolTipTimeDisplayed(Object object) {
return 5000;
}
@Override
public void update(ViewerCell cell) {
if (cell.getElement() instanceof ArduinoPlatformPackageIndex) {
cell.setText(((ArduinoPlatformPackageIndex) cell.getElement()).getName());
}
if (cell.getElement() instanceof ArduinoPackage) {
cell.setText(((ArduinoPackage) cell.getElement()).getName());
}
if (cell.getElement() instanceof ArduinoPlatform) {
cell.setText(((ArduinoPlatform) cell.getElement()).getName());
}
if (cell.getElement() instanceof InstallableVersion) {
cell.setText(((InstallableVersion) cell.getElement()).getVersion().toString());
}
}
});
return viewer1;
}
};
this.viewer = this.myGuiplatformTree.getViewer();
ColumnViewerToolTipSupport.enableFor(this.viewer);
this.myGuiplatformTree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
this.viewer.setInput(EMPTY_STRING);
return control;
}
Aggregations