Search in sources :

Example 6 with SetFileEncodingDialog

use of com.cubrid.common.ui.query.dialog.SetFileEncodingDialog in project cubrid-manager by CUBRID.

the class FavoriteQueryNavigatorView method addFile.

/**
	 * Add a favorite by external sql file(s).
	 */
private void addFile() {
    Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
    String charset = StringUtil.getDefaultCharset();
    SetFileEncodingDialog dialog = new SetFileEncodingDialog(shell, charset, true);
    if (dialog.open() != IDialogConstants.OK_ID) {
        return;
    }
    String memo = null;
    try {
        CubridDatabase cubridDatabase = getCurrentDatabase();
        memo = cubridDatabase.getDatabaseInfo().getDbName() + "@" + cubridDatabase.getServer().getServerInfo().getHostAddress();
    } catch (Exception e) {
        memo = "";
    }
    String filenameToSave = dialog.getFilePath();
    File file = new File(filenameToSave);
    String pathname = file.getPath();
    String filename = file.getName();
    int sp = pathname.indexOf(filename);
    if (sp != -1) {
        pathname = pathname.substring(0, sp);
    }
    lastDirectory = pathname;
    charset = dialog.getEncoding();
    addFavoriteByFileLink(lastDirectory, filename, memo, charset);
}
Also used : Shell(org.eclipse.swt.widgets.Shell) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase) SetFileEncodingDialog(com.cubrid.common.ui.query.dialog.SetFileEncodingDialog) File(java.io.File) PartInitException(org.eclipse.ui.PartInitException) IOException(java.io.IOException) Point(org.eclipse.swt.graphics.Point)

Aggregations

SetFileEncodingDialog (com.cubrid.common.ui.query.dialog.SetFileEncodingDialog)6 IOException (java.io.IOException)3 PartInitException (org.eclipse.ui.PartInitException)3 QueryEditorPart (com.cubrid.common.ui.query.editor.QueryEditorPart)2 QueryUnit (com.cubrid.common.ui.query.editor.QueryUnit)2 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)2 File (java.io.File)2 IEditorPart (org.eclipse.ui.IEditorPart)2 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)2 SQLEditorComposite (com.cubrid.common.ui.query.control.SQLEditorComposite)1 Point (org.eclipse.swt.graphics.Point)1 Shell (org.eclipse.swt.widgets.Shell)1 IEditorInput (org.eclipse.ui.IEditorInput)1