Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pub support #107

Merged
merged 19 commits into from Jul 31, 2019
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

Add support for --offline and use NLS for messages

Signed-off-by: Jonas Hungershausen <jonas.hungershausen@vogella.com>
  • Loading branch information...
jonas-jonas committed Jul 24, 2019
commit be7bfb6cf04dc46a5becab8db1fd3851715603b0
@@ -25,7 +25,10 @@ Require-Bundle: org.eclipse.ui.genericeditor;bundle-version="1.0.0",
org.eclipse.tm4e.ui,
com.google.guava;bundle-version="21.0.0",
org.eclipse.lsp4j.jsonrpc
Import-Package: org.osgi.service.component.annotations;version="1.3.0",
Import-Package: org.eclipse.e4.core.contexts;version="1.7.0",
org.eclipse.e4.core.di;version="1.7.0",
org.eclipse.e4.core.di.annotations;version="1.6.0",
org.osgi.service.component.annotations;version="1.3.0",
org.slf4j,
org.slf4j.spi
Service-Component: OSGI-INF/org.eclipse.dartboard.ListenerService.xml
@@ -6,7 +6,8 @@ Launch_NoProjectSelected_Body=Please select a project to launch
Launch_Project=Project:
Preference_SDKLocation=Dart SDK &Location:
Preference_SDKVersion=Dart SDK Version:
Preference_PubAutoSync=Pub dependency synchronization
Preference_PubAutoSync_Label=Automatic &Pub dependency synchronization
Preference_PubOffline_Label=Use cached packages (--&offline flag)
Launch_SDKLocation_Message=The location the Dart SDK is installed to
Launch_MainClass=Main class:
Launch_MainClass_Message=Entry point to your Dart program
@@ -39,3 +40,7 @@ NewFile_OpeningFile=Opening file for editing...
PubSync_Job_Name=Resolving pub dependencies of {0}
PubSync_Task_ResolvingDependencies=Resolving dependencies...
PubSync_Task_PrecompilingExecutables=Precompiling executables...
PubSync_CouldNotDeterminePath=Could not determine path for project {0}. \n\
Maybe the project setup is defective?
PubSync_CouldNotStartProcess=Could not start pub process.
Error_CouldNotRefreshResource=Could not refresh resource {0}.
@@ -25,8 +25,16 @@ private Constants() {
*/
public static final String PREFERENCES_SDK_LOCATION = "sdk_location"; //$NON-NLS-1$

/**
* Preferences key for the option to automatically sync pub dependencies on pubspec.yaml file save.
*/
public static final String PREFERENCES_SYNC_PUB = "auto_pub_sync"; //$NON-NLS-1$

/**
* Preferences key for the --offline flag to pub get operations
*/
public static final String PREFERENCES_OFFLINE_PUB = "offline_pub"; //$NON-NLS-1$

/**
* Plugin ID of the plugin
*/
@@ -1,17 +1,38 @@
/*******************************************************************************
* Copyright (c) 2019 vogella GmbH 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:
* Jonas Hungershausen - initial API and implementation
*******************************************************************************/
package org.eclipse.dartboard;

import javax.inject.Inject;

import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.dartboard.pub.PubspecChangeListener;
import org.eclipse.e4.core.contexts.ContextInjectionFactory;
import org.eclipse.e4.core.contexts.IEclipseContext;
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;

@Component(immediate = true)
public class ListenerService {

@Inject
IEclipseContext context;

@Activate
public void registerListeners() {
IWorkspace workspace = ResourcesPlugin.getWorkspace();
workspace.addResourceChangeListener(new PubspecChangeListener());
workspace.addResourceChangeListener(ContextInjectionFactory.make(PubspecChangeListener.class, context));
}
}

}
@@ -26,7 +26,8 @@
public static String Launch_Project;
public static String Preference_SDKLocation;
public static String Preference_SDKVersion;
public static String Preference_PubAutoSync;
public static String Preference_PubAutoSync_Label;
public static String Preference_PubOffline_Label;
public static String Launch_SDKLocation_Message;
public static String Launch_MainClass;
public static String Launch_MainClass_Message;
@@ -58,6 +59,9 @@
public static String PubSync_Job_Name;
public static String PubSync_Task_ResolvingDependencies;
public static String PubSync_Task_PrecompilingExecutables;
public static String PubSync_CouldNotDeterminePath;
public static String PubSync_CouldNotStartProcess;
public static String Error_CouldNotRefreshResource;

static {
NLS.initializeMessages("assets.messages", Messages.class);
@@ -20,11 +20,11 @@
import java.nio.file.Paths;
import java.util.Optional;

import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.dartboard.Constants;
import org.eclipse.dartboard.Messages;
import org.eclipse.dartboard.util.DartUtil;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.ui.preferences.ScopedPreferenceStore;
import org.slf4j.Logger;
@@ -59,6 +59,7 @@ public void initializeDefaultPreferences() {
}
}
scopedPreferenceStore.setDefault(Constants.PREFERENCES_SYNC_PUB, true);
scopedPreferenceStore.setDefault(Constants.PREFERENCES_OFFLINE_PUB, false);
}

/**
@@ -80,7 +81,7 @@ public void initializeDefaultPreferences() {
public Optional<Path> getDartLocation() {
Path path = null; // $NON-NLS-1$
String[] command;
if (Platform.OS_WIN32.equals(Platform.getOS())) {
if (DartUtil.IS_WINDOWS) {
command = new String[] { "cmd", "/c", "where dart" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
} else {
command = new String[] { "/bin/bash", "-c", "which dart" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
@@ -56,6 +56,7 @@
private DartSDKLocationFieldEditor dartSDKLocationEditor;

private BooleanFieldEditor autoPubSyncEditor;
private BooleanFieldEditor useOfflinePub;

public DartPreferencePage() {
super(GRID);
@@ -101,7 +102,7 @@ public boolean performOk() {
} catch (IOException e) {
e.printStackTrace();
}

Display.getDefault().asyncExec(() -> {
PlatformUI.getWorkbench().restart(true);
});
@@ -145,9 +146,12 @@ protected void createFieldEditors() {
dartSDKLocationEditor.addModifyListener(event -> {
setValid(dartSDKLocationEditor.doCheckState());
});
autoPubSyncEditor = new BooleanFieldEditor(Constants.PREFERENCES_SYNC_PUB, Messages.Preference_PubAutoSync,
parent);
autoPubSyncEditor = new BooleanFieldEditor(Constants.PREFERENCES_SYNC_PUB,
Messages.Preference_PubAutoSync_Label, parent);
addField(autoPubSyncEditor);
useOfflinePub = new BooleanFieldEditor(Constants.PREFERENCES_OFFLINE_PUB, Messages.Preference_PubOffline_Label,
parent);
addField(useOfflinePub);
}

/**

This file was deleted.

ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.