Пример #1
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
                {
                    IGraph cs = new Graph();
                    cs.LoadFromFile(this.ofdConnection.FileName);
                    IConnectionsGraph connections = new ConnectionsGraph(cs, this.ofdConnection.FileName);

                    OpenConnectionForm openConnections = new OpenConnectionForm(connections);
                    openConnections.MdiParent = this;
                    if (openConnections.ShowDialog() == DialogResult.OK)
                    {
                        Connection connection = openConnections.Connection;
                        ShowStoreManagerForm(connection);
                    }
                }
                catch (RdfParseException)
                {
                    MessageBox.Show(Resources.OpenConnection_InvalidFile_Text, Resources.OpenConnection_Error_Title, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(string.Format(Resources.OpenConnection_Error_Text, ex.Message), Resources.OpenConnection_Error_Title, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Пример #2
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)
                    {
                        IStorageProvider 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);
                }
            }
        }
 private void btnBrowse_Click(object sender, EventArgs e)
 {
     this.sfdExport.Filter = MimeTypesHelper.GetFilenameFilter(false, false, true, false, false, false);
     if (this.sfdExport.ShowDialog() == DialogResult.OK)
     {
         this.txtFile.Text = this.sfdExport.FileName;
     }
 }
Пример #4
0
 private void btnLoadQuery_Click(object sender, EventArgs e)
 {
     this.ofdQuery.Filter = MimeTypesHelper.GetFilenameFilter(false, false, false, true, false, true);
     if (this.ofdQuery.ShowDialog() == DialogResult.OK)
     {
         using (StreamReader reader = new StreamReader(this.ofdQuery.FileName))
         {
             this.txtSparqlQuery.Text = reader.ReadToEnd();
         }
     }
 }
Пример #5
0
 private void btnSaveQuery_Click(object sender, EventArgs e)
 {
     this.sfdQuery.Filter = MimeTypesHelper.GetFilenameFilter(false, false, false, true, false, true);
     if (this.sfdQuery.ShowDialog() == DialogResult.OK)
     {
         using (StreamWriter writer = new StreamWriter(this.sfdQuery.FileName))
         {
             writer.Write(this.txtSparqlQuery.Text);
         }
     }
 }
Пример #6
0
        private void mnuSaveConnection_Click(object sender, EventArgs e)
        {
            if (this.ActiveMdiChild != null)
            {
                if (this.ActiveMdiChild is StoreManagerForm)
                {
                    try
                    {
                        Connection connection = ((StoreManagerForm)this.ActiveMdiChild).Connection;
                        this.sfdConnection.Filter = MimeTypesHelper.GetFilenameFilter(true, false, false, false, false, false);
                        if (this.sfdConnection.ShowDialog() == DialogResult.OK)
                        {
                            //Append to existing configuration file or overwrite?
                            IGraph cs = new Graph();
                            if (File.Exists(this.sfdConnection.FileName))
                            {
                                DialogResult result = MessageBox.Show(Resources.SaveConnection_Append_Text, Resources.SaveConnection_Append_Title, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
                                switch (result)
                                {
                                case DialogResult.Yes:
                                    // Load in existing connections
                                    cs.LoadFromFile(this.sfdConnection.FileName);
                                    break;

                                case DialogResult.No:
                                    File.Delete(this.sfdConnection.FileName);
                                    break;

                                default:
                                    return;
                                }
                            }

                            // Open the connections file and add to it which automatically causes it to be saved
                            IConnectionsGraph connections = new ConnectionsGraph(cs, this.sfdConnection.FileName);
                            connections.Add(connection);
                        }
                    }
                    catch (Exception ex)
                    {
                        Program.HandleInternalError(Resources.SaveConnection_Error, ex);
                    }
                }
                else
                {
                    this.mnuSaveConnection.Enabled = false;
                }
            }
            else
            {
                this.mnuSaveConnection.Enabled = false;
            }
        }
Пример #7
0
        public fclsSparqlGui()
        {
            InitializeComponent();
            Constants.WindowIcon = this.Icon;
            this._store          = new TripleStore();
            this._dataset        = new InMemoryQuadDataset(this._store);
            this._processor      = new LeviathanQueryProcessor(this._dataset);

            //Enable UTF-8 BOM setting if user set
            Options.UseBomForUtf8 = false;
            if (Properties.Settings.Default.UseUtf8Bom)
            {
                Options.UseBomForUtf8      = true;
                this.chkUseUtf8Bom.Checked = true;
            }

            String temp = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
            String sep  = new String(new char[] { Path.DirectorySeparatorChar });

            if (!temp.EndsWith(sep))
            {
                temp += sep;
            }
            temp = Path.Combine(temp, @"dotNetRDF\");
            if (!System.IO.Directory.Exists(temp))
            {
                System.IO.Directory.CreateDirectory(temp);
            }
            temp = Path.Combine(temp, @"SparqlGUI\");
            if (!System.IO.Directory.Exists(temp))
            {
                System.IO.Directory.CreateDirectory(temp);
            }
            this._logfile = Path.Combine(temp, "SparqlGui-" + DateTime.Now.ToString("MMM-yyyy") + ".log");

            this.ofdBrowse.Filter = MimeTypesHelper.GetFilenameFilter(true, true, false, false, false, true);
            this.ofdQuery.Filter  = MimeTypesHelper.GetFilenameFilter(false, false, false, true, false, true);
        }
Пример #8
0
        private void mnuSaveConnection_Click(object sender, EventArgs e)
        {
            if (this.ActiveMdiChild != null)
            {
                if (this.ActiveMdiChild is StoreManagerForm)
                {
                    Object manager;
                    if (this.ActiveMdiChild is StoreManagerForm)
                    {
                        manager = ((StoreManagerForm)this.ActiveMdiChild).Manager;
                    }
                    else
                    {
                        return;
                    }
                    if (manager is IConfigurationSerializable)
                    {
                        this.sfdConnection.Filter = MimeTypesHelper.GetFilenameFilter(true, false, false, false, false, false);
                        if (this.sfdConnection.ShowDialog() == DialogResult.OK)
                        {
                            //Append to existing configuration file or overwrite?
                            ConfigurationSerializationContext context;
                            if (File.Exists(this.sfdConnection.FileName))
                            {
                                DialogResult result = MessageBox.Show("The selected connection file already exists - would you like to append this connection to that file?  Click Yes to append to this file, No to overwrite and Cancel to abort", "Append Connection?", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
                                switch (result)
                                {
                                case DialogResult.Yes:
                                    Graph g = new Graph();
                                    FileLoader.Load(g, this.sfdConnection.FileName);
                                    context = new ConfigurationSerializationContext(g);
                                    break;

                                case DialogResult.No:
                                    context = new ConfigurationSerializationContext();
                                    break;

                                default:
                                    return;
                                }
                            }
                            else
                            {
                                //Create new configuration file
                                context = new ConfigurationSerializationContext();
                            }

                            //Save the Connection
                            ((IConfigurationSerializable)manager).SerializeConfiguration(context);

                            try
                            {
                                IRdfWriter writer = MimeTypesHelper.GetWriterByFileExtension(MimeTypesHelper.GetTrueFileExtension(this.sfdConnection.FileName));
                                writer.Save(context.Graph, this.sfdConnection.FileName);
                            }
                            catch (RdfWriterSelectionException)
                            {
                                CompressingTurtleWriter ttlwriter = new CompressingTurtleWriter(WriterCompressionLevel.High);
                                ttlwriter.Save(context.Graph, this.sfdConnection.FileName);
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show("Unable to save the current connection as it does not support this feature", "Save Unavailable", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                else
                {
                    this.mnuSaveConnection.Enabled = false;
                }
            }
            else
            {
                this.mnuSaveConnection.Enabled = false;
            }
        }