use of org.eclipse.emf.ecore.EObject in project xtext-eclipse by eclipse.
the class DomainmodelLabelProvider method doGetImage.
@Override
protected Object doGetImage(final Object element) {
if (((element instanceof EObject) && (!(element instanceof JvmIdentifiableElement)))) {
StringConcatenation _builder = new StringConcatenation();
String _name = ((EObject) element).eClass().getName();
_builder.append(_name);
_builder.append(".gif");
return _builder;
}
return super.doGetImage(element);
}
use of org.eclipse.emf.ecore.EObject in project archi by archimatetool.
the class CanvasBlockUIProviderTests method testShouldExposeFeature.
@Override
public void testShouldExposeFeature() {
EObject instance = createInstanceForExpectedClass();
provider.setInstance(instance);
assertFalse(provider.shouldExposeFeature(IArchimatePackage.Literals.LINE_OBJECT__LINE_COLOR));
assertTrue(provider.shouldExposeFeature(null));
}
use of org.eclipse.emf.ecore.EObject in project archi by archimatetool.
the class NewArchimateModelFromTemplateWizard method performFinish.
@Override
public boolean performFinish() {
// Get template
ITemplate template = fMainPage.getSelectedTemplate();
if (template == null) {
return false;
}
getContainer().getShell().setVisible(false);
fErrorMessage = null;
final File zipFile = template.getFile();
if (zipFile != null && zipFile.exists()) {
BusyIndicator.showWhile(Display.getCurrent(), new Runnable() {
@Override
public void run() {
try {
// $NON-NLS-1$
File tmp = File.createTempFile("~architemplate", null);
tmp.deleteOnExit();
File file = ZipUtils.extractZipEntry(zipFile, TemplateManager.ZIP_ENTRY_MODEL, tmp);
if (file != null && file.exists()) {
IArchimateModel model = IEditorModelManager.INSTANCE.openModel(file);
if (model != null) {
// New name
// $NON-NLS-1$
model.setName(Messages.NewArchimateModelFromTemplateWizard_1 + " " + model.getName());
// Set latest model version (need to do this in case we immediately save as Template)
model.setVersion(ModelVersion.VERSION);
// Set file to null
model.setFile(null);
// New IDs
model.setId(model.getIDAdapter().getNewID());
for (Iterator<EObject> iter = model.eAllContents(); iter.hasNext(); ) {
EObject eObject = iter.next();
if (eObject instanceof IIdentifier) {
((IIdentifier) eObject).setId(model.getIDAdapter().getNewID());
}
}
// Edit in-place in Tree
UIRequestManager.INSTANCE.fireRequest(new TreeEditElementRequest(this, model));
} else {
fErrorMessage = Messages.NewArchimateModelFromTemplateWizard_2;
}
} else {
fErrorMessage = Messages.NewArchimateModelFromTemplateWizard_2;
}
tmp.delete();
} catch (IOException ex) {
ex.printStackTrace();
fErrorMessage = ex.getMessage();
}
}
});
}
if (fErrorMessage != null) {
MessageDialog.openError(getShell(), Messages.NewArchimateModelFromTemplateWizard_3, fErrorMessage);
getContainer().getShell().setVisible(true);
}
return fErrorMessage == null;
}
use of org.eclipse.emf.ecore.EObject in project archi by archimatetool.
the class TextPositionSection method createControls.
@Override
protected void createControls(Composite parent) {
SelectionAdapter adapter = new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
for (int i = 0; i < fPositionButtons.length; i++) {
// Select/deselects
fPositionButtons[i].setSelection(e.widget == fPositionButtons[i]);
// Commands
if (fPositionButtons[i] == e.widget) {
int position = (Integer) fPositionButtons[i].getData();
CompoundCommand result = new CompoundCommand();
for (EObject textPosition : getEObjects()) {
if (((ITextPosition) textPosition).getTextPosition() != position && isAlive(textPosition)) {
Command cmd = new TextPositionCommand((ITextPosition) textPosition, position);
if (cmd.canExecute()) {
result.add(cmd);
}
}
}
executeCommand(result.unwrap());
}
}
}
};
// $NON-NLS-1$
createLabel(parent, Messages.TextPositionSection_3 + ":", ITabbedLayoutConstants.STANDARD_LABEL_WIDTH, SWT.CENTER);
Composite client = createComposite(parent, 3);
for (int i = 0; i < fPositionButtons.length; i++) {
fPositionButtons[i] = new Button(client, SWT.TOGGLE | SWT.FLAT);
// Need to do it this way for Mac
getWidgetFactory().adapt(fPositionButtons[i], true, true);
fPositionButtons[i].addSelectionListener(adapter);
}
// Top Button
fPositionButtons[0].setImage(IArchiImages.ImageFactory.getImage(IArchiImages.ICON_ALIGN_TEXT_TOP));
fPositionButtons[0].setData(ITextPosition.TEXT_POSITION_TOP);
// Middle Button
fPositionButtons[1].setImage(IArchiImages.ImageFactory.getImage(IArchiImages.ICON_ALIGN_TEXT_MIDDLE));
fPositionButtons[1].setData(ITextPosition.TEXT_POSITION_CENTRE);
// Bottom Button
fPositionButtons[2].setImage(IArchiImages.ImageFactory.getImage(IArchiImages.ICON_ALIGN_TEXT_BOTTOM));
fPositionButtons[2].setData(ITextPosition.TEXT_POSITION_BOTTOM);
// Help
PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, HELP_ID);
}
use of org.eclipse.emf.ecore.EObject in project applause by applause.
the class ScreenCompiler method doGenerate.
public void doGenerate(final Resource resource, final IFileSystemAccess fsa) {
TreeIterator<EObject> _allContents = resource.getAllContents();
Iterable<EObject> _iterable = IteratorExtensions.<EObject>toIterable(_allContents);
Iterable<Screen> _filter = Iterables.<Screen>filter(_iterable, Screen.class);
final Procedure1<Screen> _function = new Procedure1<Screen>() {
public void apply(final Screen it) {
ScreenKind _kind = it.getKind();
final ScreenKind getKind = _kind;
boolean _matched = false;
if (!_matched) {
if (Objects.equal(getKind, ScreenKind.DEFAULT_LIST)) {
_matched = true;
ScreenCompiler.this.defaultListScreenCompiler.doGenerate(it, fsa);
}
}
if (!_matched) {
if (Objects.equal(getKind, ScreenKind.DEFAULT_DETAILS)) {
_matched = true;
ScreenCompiler.this.defaultDetailsScreenCompiler.doGenerate(it, fsa);
}
}
}
};
IterableExtensions.<Screen>forEach(_filter, _function);
}
Aggregations