Example #1
0
        private void FillConnectionList(IGraph config, ListBox lbox)
        {
             SparqlParameterizedString query = new SparqlParameterizedString();
            query.Namespaces.AddNamespace("rdfs", new Uri(NamespaceMapper.RDFS));
            query.Namespaces.AddNamespace("dnr", new Uri(ConfigurationLoader.ConfigurationNamespace));

            query.CommandText = "SELECT * WHERE { ?obj a " + ConfigurationLoader.ClassGenericManager + " . OPTIONAL { ?obj rdfs:label ?label } }";
            query.CommandText += " ORDER BY DESC(?obj)";

            SparqlResultSet results = config.ExecuteQuery(query) as SparqlResultSet;
            if (results != null)
            {
                foreach (SparqlResult r in results)
                {
                    QuickConnect connect;
                    if (r.HasValue("label") && r["label"] != null)
                    {
                        connect = new QuickConnect(config, r["obj"], r["label"].ToString());
                    }
                    else
                    {
                        connect = new QuickConnect(config, r["obj"]);
                    }
                    lbox.Items.Add(connect);
                }
            }
            lbox.DoubleClick += new EventHandler((sender, args) =>
                {
                    QuickConnect connect = lbox.SelectedItem as QuickConnect;
                    if (connect != null)
                    {
                        try
                        {
                            IGenericIOManager manager = connect.GetConnection();
                            StoreManagerForm storeManager = new StoreManagerForm(manager);
                            storeManager.MdiParent = Program.MainForm;
                            storeManager.Show();

                            //Add to Recent Connections
                            Program.MainForm.AddRecentConnection(manager);

                            this.Close();
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show("Error Opening Connection " + connect.ToString() + ":\n" + ex.Message, "Connection Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                });
        }
Example #2
0
        private void btnNewConnection_Click(object sender, EventArgs e)
        {
            NewConnectionForm newConn = new NewConnectionForm();
            if (newConn.ShowDialog() == DialogResult.OK)
            {
                IGenericIOManager manager = newConn.Connection;
                StoreManagerForm storeManager = new StoreManagerForm(manager);
                storeManager.MdiParent = Program.MainForm;
                storeManager.Show();

                //Add to Recent Connections
                Program.MainForm.AddRecentConnection(manager);

                this.Close();
            }
        }
Example #3
0
        private void QuickConnectClick(object sender, EventArgs e)
        {
            if (sender == null) return;
            Object tag = null;
            if (sender is Control)
            {
                tag = ((Control)sender).Tag;
            }
            else if (sender is ToolStripItem)
            {
                tag = ((ToolStripItem)sender).Tag;
            }
            else if (sender is Menu)
            {
                tag = ((Menu)sender).Tag;
            }

            if (tag != null)
            {
                if (tag is QuickConnect)
                {
                    QuickConnect qc = (QuickConnect)tag;
                    try
                    {
                        IGenericIOManager manager = qc.GetConnection();
                        StoreManagerForm genManager = new StoreManagerForm(manager);
                        genManager.MdiParent = this;
                        genManager.Show();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Unable to load the Connection due to an error: " + ex.Message, "Quick Connect Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
            }
        }
Example #4
0
        private void mnuNewConnection_Click(object sender, EventArgs e)
        {
            NewConnectionForm newConn = new NewConnectionForm();
            newConn.StartPosition = FormStartPosition.CenterParent;
            if (newConn.ShowDialog() == DialogResult.OK)
            {
                IGenericIOManager manager = newConn.Connection;
                StoreManagerForm storeManager = new StoreManagerForm(manager);
                storeManager.MdiParent = this;
                storeManager.Show();

                //Add to Recent Connections
                this.AddRecentConnection(manager);
            }
        }
Example #5
0
        private void mnuOpenConnection_Click(object sender, EventArgs e)
        {
            this.ofdConnection.Filter = MimeTypesHelper.GetFilenameFilter(true, false, false, false, false, false);
            if (this.ofdConnection.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    Graph g = new Graph();
                    FileLoader.Load(g, this.ofdConnection.FileName);

                    OpenConnectionForm openConnections = new OpenConnectionForm(g);
                    openConnections.MdiParent = this;
                    if (openConnections.ShowDialog() == DialogResult.OK)
                    {
                        IGenericIOManager manager = openConnections.Connection;
                        StoreManagerForm genManagerForm = new StoreManagerForm(manager);
                        genManagerForm.MdiParent = this;
                        genManagerForm.Show();

                        //Add to Recent Connections
                        this.AddRecentConnection(manager);
                    }
                }
                catch (RdfParseException)
                {
                    MessageBox.Show("Unable to open a connection from the given file as it was not a valid RDF Graph or was in a format that the library does not understand", "Open Connection Failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Unable to open the given file due to the following error:\n" + ex.Message, "Open Connection Failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }