Search in sources :

Example 21 with Engine

use of com.ramussoft.common.Engine in project ramus by Vitaliy-Yakovchuk.

the class Client method run.

public void run(final String[] args) {
    final SplashScreen screen = new SplashScreen() {

        /**
         */
        private static final long serialVersionUID = -4641958771849938048L;

        @Override
        protected String getImageName() {
            for (String s : args) if (s.equals("-season"))
                return "/com/ramussoft/season/about.png";
            return "/com/ramussoft/gui/about.png";
        }
    };
    if (Metadata.CLIENT) {
        Metadata.REGISTERED_FOR = ClientConnection.getName();
        Metadata.DEMO_REGISTERED = ClientConnection.getName() != null;
    }
    screen.setLocationRelativeTo(null);
    boolean hide = false;
    for (String s : args) if ("--hide-splash".equals(s))
        hide = true;
    if (!hide)
        screen.setVisible(true);
    Thread t = new Thread(new Runnable() {

        @Override
        public void run() {
            List<PluginProvider> suits = new ArrayList<PluginProvider>();
            suits.add(new SimpleAttributePluginSuit());
            initAdditionalPluginSuits(suits);
            PluginFactory factory = createPluginFactory(suits);
            PersistentFactory persistentFactory = new PersistentFactory(null, factory.getAttributePlugins(), null);
            persistentFactory.reinit();
            Engine engine = getEngine(factory, persistentFactory);
            AccessRules rules = getAccessRules();
            e = engine;
            e.setPluginProperty("Core", "PluginList", factory.getPlugins());
            e.setPluginProperty("Core", "PluginFactory", factory);
            LightClient.staticEngine = e;
            LightClient.staticAccessRules = rules;
            List<GUIPlugin> list = new ArrayList<GUIPlugin>();
            QualifierPluginSuit.addPlugins(list, e, rules);
            initAdditionalGuiPlugins(list);
            User me = getMe();
            List<Group> groups = me.getGroups();
            String[] grps = new String[groups.size()];
            for (int i = 0; i < grps.length; i++) grps[i] = groups.get(i).getName();
            AbstractGUIPluginFactory factory1;
            String ws = Options.getString("WindowsControl", "simple");
            if (ws.equals("simple"))
                factory1 = new SimleGUIPluginFactory(list, e, rules, getType(), grps, loadPlugins);
            else
                factory1 = new GUIPluginFactory(list, e, rules, getType(), grps, loadPlugins);
            framework = factory1.getFramework();
            framework.addCloseMainFrameListener(new CloseMainFrameAdapter() {

                @Override
                public void afterClosed() {
                    Client.this.close();
                }
            });
            final JFrame frame = factory1.getMainFrame();
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            String title = getTitle();
            frame.setTitle(title);
            SwingUtilities.invokeLater(new Runnable() {

                public void run() {
                    frame.setVisible(true);
                    screen.setVisible(false);
                }
            });
        }
    });
    t.start();
    Thread thread = new Thread("Icons-buffer-cleaner") {

        @Override
        public void run() {
            while (true) {
                try {
                    Thread.sleep(20000);
                    IconFactory.clearIconsBuffer(LightClient.staticEngine);
                    IconFactory.clearQualifierIconsBuffer(LightClient.staticEngine);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }
    };
    thread.setDaemon(true);
    thread.setPriority(Thread.MIN_PRIORITY);
    thread.start();
}
Also used : PersistentFactory(com.ramussoft.core.persistent.PersistentFactory) SimleGUIPluginFactory(com.ramussoft.gui.core.simple.SimleGUIPluginFactory) User(com.ramussoft.net.common.User) AbstractGUIPluginFactory(com.ramussoft.gui.common.AbstractGUIPluginFactory) SimleGUIPluginFactory(com.ramussoft.gui.core.simple.SimleGUIPluginFactory) GUIPluginFactory(com.ramussoft.gui.core.GUIPluginFactory) PluginProvider(com.ramussoft.common.PluginProvider) CloseMainFrameAdapter(com.ramussoft.gui.common.event.CloseMainFrameAdapter) SimpleAttributePluginSuit(com.ramussoft.core.attribute.simple.SimpleAttributePluginSuit) JFrame(javax.swing.JFrame) SplashScreen(com.ramussoft.gui.common.SplashScreen) AccessRules(com.ramussoft.common.AccessRules) ArrayList(java.util.ArrayList) List(java.util.List) AbstractGUIPluginFactory(com.ramussoft.gui.common.AbstractGUIPluginFactory) SimleGUIPluginFactory(com.ramussoft.gui.core.simple.SimleGUIPluginFactory) GUIPluginFactory(com.ramussoft.gui.core.GUIPluginFactory) PluginFactory(com.ramussoft.common.PluginFactory) Engine(com.ramussoft.common.Engine) GUIPlugin(com.ramussoft.gui.common.GUIPlugin) AbstractGUIPluginFactory(com.ramussoft.gui.common.AbstractGUIPluginFactory)

Example 22 with Engine

use of com.ramussoft.common.Engine in project ramus by Vitaliy-Yakovchuk.

the class AbstractChartSetupEditor method createComponent.

@Override
public JComponent createComponent(GUIFramework framework, Element element) {
    this.framework = framework;
    ChartSource chartSource = new ChartSource(framework.getEngine());
    if (element != null) {
        Engine engine = framework.getEngine();
        chartSource.load(engine.getInputStream(getPreferencesPath(element, StandardAttributesPlugin.getAttributeNameAttribute(engine))));
    }
    component = new ChartSourceSelectPanel(framework, chartSource);
    return component;
}
Also used : ChartSource(com.ramussoft.chart.ChartSource) Engine(com.ramussoft.common.Engine)

Example 23 with Engine

use of com.ramussoft.common.Engine in project ramus by Vitaliy-Yakovchuk.

the class SectorColorAttributePlugin method getAttributeEditor.

@Override
public AttributeEditor getAttributeEditor(final Engine engine, final AccessRules rules, final Element element, final Attribute attribute, AttributeEditor old) {
    if (old != null)
        old.close();
    return new AbstractAttributeEditor() {

        private PaintSector.Pin pin;

        private JColorChooser component;

        private Color color;

        {
            component = new JColorChooser();
        }

        @Override
        public Object setValue(Object value) {
            this.pin = (PaintSector.Pin) value;
            color = pin.getSector().getColor();
            component.setColor(color);
            return value;
        }

        @Override
        public Object getValue() {
            return pin;
        }

        @Override
        public void apply(Engine engine, Element element, Attribute attribute, Object value) {
            SectorColorAttributePlugin.this.apply(component.getColor(), pin);
        }

        @Override
        public JComponent getComponent() {
            return component;
        }

        @Override
        public boolean isSaveAnyway() {
            return !color.equals(component.getColor());
        }
    };
}
Also used : AbstractAttributeEditor(com.ramussoft.gui.common.AbstractAttributeEditor) Pin(com.ramussoft.pb.idef.elements.PaintSector.Pin) PaintSector(com.ramussoft.pb.idef.elements.PaintSector) Attribute(com.ramussoft.common.Attribute) Color(java.awt.Color) Element(com.ramussoft.common.Element) JColorChooser(javax.swing.JColorChooser) Engine(com.ramussoft.common.Engine)

Example 24 with Engine

use of com.ramussoft.common.Engine in project ramus by Vitaliy-Yakovchuk.

the class HTTPParser method printFile.

private void printFile() throws IOException {
    long elementId = Long.parseLong(params.get("id"));
    long attributeId = Long.parseLong(params.get("attr"));
    Engine engine = dataPlugin.getEngine();
    FilePlugin plugin = (FilePlugin) engine.getPluginProperty("Core", FilePlugin.PLUGIN_NAME);
    String string = plugin.getFilePath(elementId, attributeId);
    List<Persistent>[] lists = engine.getBinaryAttribute(elementId, attributeId);
    if (lists[0].size() > 0) {
        FilePersistent fp = (FilePersistent) lists[0].get(0);
        String userAgent = request.getUserAgent();
        String encodedFileName = null;
        if ((userAgent != null) && (userAgent.contains("MSIE") || userAgent.contains("Opera"))) {
            encodedFileName = URLEncoder.encode(fp.getName(), "UTF-8");
        } else {
            byte[] bytes = fp.getName().getBytes("UTF-8");
            try {
                encodedFileName = "=?UTF-8?B?" + new String(Base64.encode(bytes), "UTF-8") + "?=";
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        if (params.get("prev") == null) {
            response.setContentDisposition("attachment; filename=" + encodedFileName);
            response.setRamusContentDisposition(toUtf8(fp.getName()));
        }
    }
    byte[] bytes = engine.getStream(string);
    response.writeHead();
    if (bytes != null)
        stream.write(bytes);
}
Also used : FilePlugin(com.ramussoft.core.attribute.simple.FilePlugin) List(java.util.List) ArrayList(java.util.ArrayList) IEngine(com.ramussoft.common.IEngine) Engine(com.ramussoft.common.Engine) DataException(com.ramussoft.report.data.DataException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) SQLException(java.sql.SQLException) IOException(java.io.IOException) FilePersistent(com.ramussoft.core.attribute.simple.FilePersistent)

Example 25 with Engine

use of com.ramussoft.common.Engine in project ramus by Vitaliy-Yakovchuk.

the class OtherElementAttributeViewer method printAttribute.

@Override
public void printAttribute(PrintStream printStream, DataPlugin dataPlugin, Element element, Attribute attribute, HTTPParser parser, AttributeViewerCallback callback) throws IOException {
    Engine engine = dataPlugin.getEngine();
    Long id = (Long) engine.getAttribute(element, attribute);
    if (id != null) {
        Element element2 = engine.getElement(id);
        if (element2 != null) {
            OtherElementPropertyPersistent pp = (OtherElementPropertyPersistent) engine.getAttribute(null, attribute);
            Attribute other = engine.getAttribute(pp.getQualifierAttribute());
            if (other != null) {
                callback.beforePrint(printStream);
                printLinkToElement(element2, engine.getAttribute(element2, other), parser, printStream);
                callback.afterPrint(printStream);
            }
        }
    }
}
Also used : Attribute(com.ramussoft.common.Attribute) Element(com.ramussoft.common.Element) Engine(com.ramussoft.common.Engine) OtherElementPropertyPersistent(com.ramussoft.core.attribute.simple.OtherElementPropertyPersistent)

Aggregations

Engine (com.ramussoft.common.Engine)85 Attribute (com.ramussoft.common.Attribute)32 ArrayList (java.util.ArrayList)30 Element (com.ramussoft.common.Element)27 Qualifier (com.ramussoft.common.Qualifier)22 AccessRules (com.ramussoft.common.AccessRules)21 List (java.util.List)19 IEngine (com.ramussoft.common.IEngine)15 Row (com.ramussoft.database.common.Row)13 IOException (java.io.IOException)11 SQLException (java.sql.SQLException)11 PluginFactory (com.ramussoft.common.PluginFactory)8 PluginProvider (com.ramussoft.common.PluginProvider)8 Journaled (com.ramussoft.common.journal.Journaled)8 CachedEngine (com.ramussoft.common.cached.CachedEngine)7 Hashtable (java.util.Hashtable)7 TreeTableNode (com.ramussoft.gui.qualifier.table.TreeTableNode)6 JournaledEngine (com.ramussoft.common.journal.JournaledEngine)5 FileIEngineImpl (com.ramussoft.core.impl.FileIEngineImpl)5 MemoryDatabase (com.ramussoft.database.MemoryDatabase)5