use of eu.esdihumboldt.hale.ui.service.project.ProjectService in project hale by halestudio.
the class SaveConfigurationInstanceExportWizard method performFinish.
@Override
public boolean performFinish() {
if (!applyConfiguration()) {
return false;
}
IOConfiguration configuration = new IOConfiguration();
// store the (export) configuration of the provider in the new IO
// configuration
configuration.setActionId(getActionId());
configuration.setProviderId(getProviderFactory().getIdentifier());
getProvider().storeConfiguration(configuration.getProviderConfiguration());
ProjectService ps = PlatformUI.getWorkbench().getService(ProjectService.class);
// target is not set here and also not needed for the configuration
configuration.getProviderConfiguration().remove(ExportProvider.PARAM_TARGET);
// add the new configuration to the export configurations of the project
ps.addExportConfiguration(configurationName, configuration);
log.userInfo(MessageFormat.format("Created export configuration ''{0}''", configurationName));
return true;
}
use of eu.esdihumboldt.hale.ui.service.project.ProjectService in project hale by halestudio.
the class ArchiveProjectExportAdvisor method prepareProvider.
@Override
public void prepareProvider(ArchiveProjectWriter provider) {
super.prepareProvider(provider);
ProjectService projectService = getService(ProjectService.class);
Project project = (Project) projectService.getProjectInfo();
// set a copy of the project
provider.setProject(project.clone());
}
use of eu.esdihumboldt.hale.ui.service.project.ProjectService in project hale by halestudio.
the class URLTargetURIFieldEditor method getTextControl.
@Override
public Text getTextControl(Composite parent) {
// ensure resource control is added before the text control
historyButton = new Button(parent, SWT.PUSH | SWT.FLAT);
historyButton.setToolTipText("Choose from recent URLs");
historyButton.setImage(CommonSharedImages.getImageRegistry().get(CommonSharedImages.IMG_HISTORY));
historyButton.setEnabled(false);
historyButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
ProjectService ps = PlatformUI.getWorkbench().getService(ProjectService.class);
final List<String> locations = ps.getConfigurationService().getList(SETTING_URL_HISTORY);
if (locations != null && !locations.isEmpty()) {
Menu filesMenu = new Menu(historyButton);
for (String locationString : locations) {
try {
final URI location = URI.create(locationString);
MenuItem item = new MenuItem(filesMenu, SWT.PUSH);
item.setText(RecentProjectsMenu.shorten(location.toString(), 80, 20));
item.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
getTextControl().setText(location.toString());
getTextControl().setFocus();
valueChanged();
onHistorySelected(location);
}
});
} catch (Exception e1) {
// ignore
}
}
Point histLoc = historyButton.getParent().toDisplay(historyButton.getLocation());
filesMenu.setLocation(histLoc.x, histLoc.y + historyButton.getSize().y);
filesMenu.setVisible(true);
}
}
});
return super.getTextControl(parent);
}
use of eu.esdihumboldt.hale.ui.service.project.ProjectService in project hale by halestudio.
the class URLTargetURIFieldEditor method getURI.
/**
* Get the entered URI.
*
* @param store if the URI should be stored in the history
* @return the URI or <code>null</code>
*/
@Nullable
public URI getURI(boolean store) {
URI uri = super.getURI();
if (uri != null && store) {
String value = uri.toString();
// store the URI in the history list
ProjectService ps = PlatformUI.getWorkbench().getService(ProjectService.class);
List<String> history = ps.getConfigurationService().getList(SETTING_URL_HISTORY);
if (history != null) {
List<String> newHistory = new ArrayList<>(history);
boolean unchanged = history.size() >= 1 && history.get(0).equals(value);
if (!unchanged) {
// remove any occurrences
while (newHistory.remove(value)) {
// nothing to do
}
// insert at beginning
newHistory.add(0, value);
while (newHistory.size() > HISTORY_MAX_SIZE) {
newHistory.remove(newHistory.size() - 1);
}
ps.getConfigurationService().setList(SETTING_URL_HISTORY, newHistory);
}
} else {
// just store the new value
ps.getConfigurationService().setList(SETTING_URL_HISTORY, Collections.singletonList(value));
}
updateHistory();
}
return uri;
}
use of eu.esdihumboldt.hale.ui.service.project.ProjectService in project hale by halestudio.
the class UserFallbackEntityResolver method resolveType.
/**
* Ask the user to select a replacement for a type.
*
* @param original the original entity
* @param candidate a candidate for the replacement
* @param schemaSpace the schema space
* @return the resolved type (may be the original)
*/
public static Type resolveType(TypeEntityDefinition original, @Nullable EntityDefinition candidate, SchemaSpaceID schemaSpace) {
ResolveCache cache = getCache();
TypeEntityDefinition replacement = cache.getReplacement(original);
if (replacement != null) {
// use cached replacement
return new DefaultType(replacement);
}
ProjectService ps = HaleUI.getServiceProvider().getService(ProjectService.class);
final AtomicBoolean canceled;
final AtomicBoolean skipped = new AtomicBoolean(false);
if (ps.getTemporaryProperty(RESOLVE_SKIP_PROPERTY, Value.of(false)).as(Boolean.class)) {
canceled = new AtomicBoolean(true);
} else {
canceled = new AtomicBoolean(false);
}
final AtomicReference<EntityDefinition> result = new AtomicReference<>();
if (!canceled.get()) {
PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
@Override
public void run() {
TypeEntityResolverDialog dlg = new TypeEntityResolverDialog(Display.getCurrent().getActiveShell(), schemaSpace, "Cell entity could not be resolved", candidate, false) {
@Override
public void create() {
super.create();
openTray(new ViewerEntityTray(original));
}
};
switch(dlg.open()) {
case Window.OK:
result.set(dlg.getObject());
break;
case Window.CANCEL:
// Don't try to resolve further entities
ps.setTemporaryProperty(RESOLVE_SKIP_PROPERTY, Value.of(true));
canceled.set(true);
break;
case TypeEntityResolverDialog.SKIP:
// skip this entity
skipped.set(true);
break;
default:
canceled.set(true);
}
}
});
}
EntityDefinition def = result.get();
if (canceled.get() || skipped.get()) {
// return the original so the cell is not lost
return new DefaultType(original);
} else if (def == null) {
// caller must take care about this
return null;
} else {
TypeEntityDefinition ted = (TypeEntityDefinition) def;
// make sure that the type is classified as mapping relevant
if (!ted.getType().getConstraint(MappingRelevantFlag.class).isEnabled()) {
SchemaService ss = PlatformUI.getWorkbench().getService(SchemaService.class);
ss.toggleMappable(schemaSpace, Collections.singleton(ted.getType()));
}
cache.put(original, ted);
return new DefaultType(ted);
}
}
Aggregations