Search in sources :

Example 46 with EObject

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);
}
Also used : JvmIdentifiableElement(org.eclipse.xtext.common.types.JvmIdentifiableElement) EObject(org.eclipse.emf.ecore.EObject) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation)

Example 47 with EObject

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));
}
Also used : EObject(org.eclipse.emf.ecore.EObject)

Example 48 with EObject

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;
}
Also used : IIdentifier(com.archimatetool.model.IIdentifier) EObject(org.eclipse.emf.ecore.EObject) Iterator(java.util.Iterator) TreeEditElementRequest(com.archimatetool.editor.views.tree.TreeEditElementRequest) ITemplate(com.archimatetool.templates.model.ITemplate) IOException(java.io.IOException) File(java.io.File) IArchimateModel(com.archimatetool.model.IArchimateModel)

Example 49 with EObject

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);
}
Also used : ITextPosition(com.archimatetool.model.ITextPosition) Composite(org.eclipse.swt.widgets.Composite) CompoundCommand(org.eclipse.gef.commands.CompoundCommand) TextPositionCommand(com.archimatetool.editor.diagram.commands.TextPositionCommand) Command(org.eclipse.gef.commands.Command) Button(org.eclipse.swt.widgets.Button) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) EObject(org.eclipse.emf.ecore.EObject) SelectionEvent(org.eclipse.swt.events.SelectionEvent) TextPositionCommand(com.archimatetool.editor.diagram.commands.TextPositionCommand) CompoundCommand(org.eclipse.gef.commands.CompoundCommand)

Example 50 with EObject

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);
}
Also used : Screen(org.applause.lang.applauseDsl.Screen) EObject(org.eclipse.emf.ecore.EObject) Procedure1(org.eclipse.xtext.xbase.lib.Procedures.Procedure1) ScreenKind(org.applause.lang.applauseDsl.ScreenKind)

Aggregations

EObject (org.eclipse.emf.ecore.EObject)7112 AntlrDatatypeRuleToken (org.eclipse.xtext.parser.antlr.AntlrDatatypeRuleToken)1950 Resource (org.eclipse.emf.ecore.resource.Resource)304 Test (org.junit.Test)301 IPropertiesEditionEvent (org.eclipse.emf.eef.runtime.api.notify.IPropertiesEditionEvent)262 PropertiesEditionEvent (org.eclipse.emf.eef.runtime.impl.notify.PropertiesEditionEvent)262 ArrayList (java.util.ArrayList)207 GridData (org.eclipse.swt.layout.GridData)198 SelectionEvent (org.eclipse.swt.events.SelectionEvent)190 URI (org.eclipse.emf.common.util.URI)189 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)187 InternalEObject (org.eclipse.emf.ecore.InternalEObject)181 ReferencesTable (org.eclipse.emf.eef.runtime.ui.widgets.ReferencesTable)162 ReferencesTableListener (org.eclipse.emf.eef.runtime.ui.widgets.ReferencesTable.ReferencesTableListener)162 ViewerFilter (org.eclipse.jface.viewers.ViewerFilter)138 ResourceSet (org.eclipse.emf.ecore.resource.ResourceSet)128 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)127 List (java.util.List)125 XtextResource (org.eclipse.xtext.resource.XtextResource)124 EReference (org.eclipse.emf.ecore.EReference)96