Search in sources :

Example 26 with DirectoryDialog

use of org.eclipse.swt.widgets.DirectoryDialog in project cubrid-manager by CUBRID.

the class ImportHostsAction method run.

/**
	 * Import hosts and groups
	 */
public void run() {
    Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
    DirectoryDialog dialog = new DirectoryDialog(shell, SWT.OPEN | SWT.APPLICATION_MODAL);
    String filePath = CommonUIPlugin.getSettingValue("IMPORT_HOSTS_WORKSPACE_KEY");
    if (null != filePath) {
        dialog.setFilterPath(filePath);
    }
    dialog.setMessage(Messages.msgSelectWorkspace);
    filePath = dialog.open();
    if (filePath == null) {
        return;
    }
    final String workspacePath = filePath;
    filePath = filePath + File.separator + ".metadata" + File.separator + ".plugins" + File.separator + "org.eclipse.core.runtime" + File.separator + ".settings" + File.separator + "com.cubrid.cubridmanager.ui.prefs";
    File file = new File(filePath);
    if (file == null || !file.exists()) {
        CommonUITool.openErrorBox(Messages.errInvalidWorkspace);
        return;
    } else {
        CommonUIPlugin.putSettingValue("IMPORT_HOSTS_WORKSPACE_KEY", workspacePath);
    }
    BusyIndicator.showWhile(Display.getDefault(), new Runnable() {

        public void run() {
            CMGroupNodePersistManager groupNodePersistManager = CMGroupNodePersistManager.getInstance();
            boolean isImportHost = CMHostNodePersistManager.getInstance().loadSevers(workspacePath);
            boolean isImportGroup = groupNodePersistManager.loadGroupNode(workspacePath);
            boolean isImportDb = CMDBNodePersistManager.getInstance().loadDatabases(workspacePath);
            if (isImportHost || isImportGroup || isImportDb) {
                CubridHostNavigatorView view = (CubridHostNavigatorView) CubridNavigatorView.getNavigatorView(CubridHostNavigatorView.ID);
                if (view != null && view.getViewer() != null) {
                    view.getViewer().refresh(true);
                }
            }
        }
    });
}
Also used : Shell(org.eclipse.swt.widgets.Shell) CMGroupNodePersistManager(com.cubrid.cubridmanager.ui.spi.persist.CMGroupNodePersistManager) File(java.io.File) CubridHostNavigatorView(com.cubrid.cubridmanager.ui.common.navigator.CubridHostNavigatorView) DirectoryDialog(org.eclipse.swt.widgets.DirectoryDialog)

Example 27 with DirectoryDialog

use of org.eclipse.swt.widgets.DirectoryDialog in project cubrid-manager by CUBRID.

the class TableUtil method getSavedDirForCreateCodes.

/**
	 * Get saved file for create php/java files
	 * 
	 * @param shell Shell
	 * @param filterPath String
	 * @return File
	 */
public static File getSavedDirForCreateCodes(Shell shell, String filterPath) {
    DirectoryDialog dialog = new DirectoryDialog(shell, SWT.SAVE | SWT.APPLICATION_MODAL);
    String filepath = filterPath;
    if (filepath == null || filepath.trim().length() == 0) {
        filepath = CommonUIPlugin.getSettingValue(TABLE_CREATE_FILE_PATH_KEY);
    }
    if (null != filepath) {
        dialog.setFilterPath(filepath);
    }
    String filePath = dialog.open();
    if (filePath == null) {
        return null;
    } else {
        File file = new File(filePath);
        CommonUIPlugin.putSettingValue(TableUtil.TABLE_CREATE_FILE_PATH_KEY, file.getAbsolutePath());
        return file;
    }
}
Also used : File(java.io.File) DirectoryDialog(org.eclipse.swt.widgets.DirectoryDialog)

Example 28 with DirectoryDialog

use of org.eclipse.swt.widgets.DirectoryDialog in project cubrid-manager by CUBRID.

the class GeneralInfoPage method createGenericVolumeGroup.

/**
	 * Create generic volume information group
	 *
	 * @param parent the parent composite
	 */
private void createGenericVolumeGroup(Composite parent) {
    Group genericVolumeGroup = new Group(parent, SWT.NONE);
    genericVolumeGroup.setText(Messages.grpGenericVolInfo);
    GridLayout layout = new GridLayout();
    layout.numColumns = 4;
    genericVolumeGroup.setLayout(layout);
    GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
    genericVolumeGroup.setLayoutData(gridData);
    Label genericSizeLabel = new Label(genericVolumeGroup, SWT.LEFT | SWT.WRAP);
    genericSizeLabel.setText(Messages.lblVolSize);
    gridData = new GridData();
    gridData.widthHint = 150;
    genericSizeLabel.setLayoutData(gridData);
    genericVolumeSizeText = new Text(genericVolumeGroup, SWT.BORDER);
    genericVolumeSizeText.setTextLimit(20);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    gridData.horizontalSpan = 3;
    genericVolumeSizeText.setLayoutData(gridData);
    genericVolumeSizeText.addFocusListener(new FocusListener() {

        public void focusGained(FocusEvent event) {
            genericVolumeSizeText.addModifyListener(GeneralInfoPage.this);
        }

        public void focusLost(FocusEvent event) {
            genericVolumeSizeText.removeModifyListener(GeneralInfoPage.this);
        }
    });
    Label genericVolumePathLabel = new Label(genericVolumeGroup, SWT.LEFT | SWT.WRAP);
    genericVolumePathLabel.setText(Messages.lblGenericVolPath);
    gridData = new GridData();
    gridData.widthHint = 150;
    genericVolumePathLabel.setLayoutData(gridData);
    genericVolumePathText = new Text(genericVolumeGroup, SWT.BORDER);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    gridData.horizontalSpan = 2;
    genericVolumePathText.setLayoutData(gridData);
    Button selectDirectoryButton = new Button(genericVolumeGroup, SWT.NONE);
    selectDirectoryButton.setText(Messages.btnBrowse);
    selectDirectoryButton.setLayoutData(CommonUITool.createGridData(1, 1, 80, -1));
    selectDirectoryButton.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            DirectoryDialog dlg = new DirectoryDialog(getShell());
            if (databasePath != null && databasePath.trim().length() > 0) {
                dlg.setFilterPath(databasePath);
            }
            dlg.setText(Messages.msgSelectDir);
            dlg.setMessage(Messages.msgSelectDir);
            String dir = dlg.open();
            if (dir != null) {
                genericVolumePathText.setText(dir);
            }
        }
    });
    ServerInfo serverInfo = server.getServerInfo();
    if (serverInfo != null && !serverInfo.isLocalServer()) {
        selectDirectoryButton.setEnabled(false);
    }
}
Also used : Group(org.eclipse.swt.widgets.Group) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text) FocusEvent(org.eclipse.swt.events.FocusEvent) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) FocusListener(org.eclipse.swt.events.FocusListener) DirectoryDialog(org.eclipse.swt.widgets.DirectoryDialog)

Example 29 with DirectoryDialog

use of org.eclipse.swt.widgets.DirectoryDialog in project cubrid-manager by CUBRID.

the class AddVolumeDialog method createDialogArea.

/**
	 * @see org.eclipse.jface.dialogs.TitleAreaDialog#createDialogArea(org.eclipse.swt.widgets.Composite)
	 * @param parent The parent composite to contain the dialog area
	 * @return the dialog area control
	 */
protected Control createDialogArea(Composite parent) {
    Composite parentComp = (Composite) super.createDialogArea(parent);
    setTitle(Messages.dialogTitle);
    setMessage(Messages.dialogMsg);
    final Composite composite = new Composite(parentComp, SWT.RESIZE);
    final GridData gdComposite = new GridData(SWT.FILL, SWT.CENTER, true, false);
    gdComposite.widthHint = 500;
    composite.setLayoutData(gdComposite);
    final GridLayout gridLayout = new GridLayout();
    gridLayout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
    gridLayout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
    gridLayout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
    gridLayout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
    composite.setLayout(gridLayout);
    final Group group = new Group(composite, SWT.NONE);
    group.setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true, false));
    final GridLayout gdGroup = new GridLayout();
    gdGroup.verticalSpacing = 0;
    group.setLayout(gdGroup);
    final Composite pathComp = new Composite(group, SWT.RESIZE);
    final GridLayout pathLayout = new GridLayout(3, false);
    pathLayout.marginBottom = 0;
    final GridData gdPathComp = new GridData(SWT.FILL, SWT.CENTER, true, false);
    pathComp.setLayout(pathLayout);
    pathComp.setLayoutData(gdPathComp);
    final GridData gdLabel = new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1);
    gdLabel.widthHint = 100;
    final Label pathLbl = new Label(pathComp, SWT.NONE);
    pathLbl.setText(Messages.pathLblName);
    pathLbl.setLayoutData(gdLabel);
    pathText = new Text(pathComp, SWT.BORDER);
    final GridData gdPathText = new GridData(SWT.FILL, SWT.CENTER, true, false);
    pathText.setLayoutData(gdPathText);
    pathText.setToolTipText(Messages.pathToolTip);
    Button selectTargetDirBtn = new Button(pathComp, SWT.NONE);
    selectTargetDirBtn.setText(Messages.btnBrowse);
    selectTargetDirBtn.setLayoutData(CommonUITool.createGridData(1, 1, 80, -1));
    selectTargetDirBtn.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            DirectoryDialog dlg = new DirectoryDialog(getShell());
            String backupDir = pathText.getText();
            if (backupDir != null && backupDir.trim().length() > 0) {
                dlg.setFilterPath(backupDir);
            }
            dlg.setText(Messages.msgSelectDir);
            dlg.setMessage(Messages.msgSelectDir);
            String dir = dlg.open();
            if (dir != null) {
                pathText.setText(dir);
            }
        }
    });
    ServerInfo serverInfo = selection.getServer().getServerInfo();
    if (serverInfo != null && !serverInfo.isLocalServer()) {
        selectTargetDirBtn.setEnabled(false);
    }
    final Composite purpComp = new Composite(group, SWT.RESIZE);
    final GridLayout purpLayout = new GridLayout(2, false);
    purpLayout.marginTop = 0;
    purpLayout.verticalSpacing = 10;
    final GridData gdPurtComp = new GridData(SWT.FILL, SWT.CENTER, true, false);
    purpComp.setLayout(purpLayout);
    purpComp.setLayoutData(gdPurtComp);
    final Label purposeLbl = new Label(purpComp, SWT.NONE);
    purposeLbl.setText(Messages.purposeLbllName);
    purposeLbl.setLayoutData(gdLabel);
    purposeCombo = new Combo(purpComp, SWT.BORDER | SWT.RIGHT | SWT.READ_ONLY);
    if (purposeEnable) {
        purposeCombo.setEnabled(true);
    } else {
        purposeCombo.setEnabled(false);
    }
    final GridData gdPurposeText = new GridData(SWT.FILL, SWT.CENTER, true, false);
    purposeCombo.setLayoutData(gdPurposeText);
    purposeCombo.setItems(itemsOfPurpose);
    final Label volumeSizeLbl = new Label(purpComp, SWT.NONE);
    volumeSizeLbl.setText(Messages.volumeSizeLblName);
    volumeSizeLbl.setLayoutData(gdLabel);
    volumeSizetext = new Text(purpComp, SWT.BORDER | SWT.RIGHT);
    final GridData gdVolumeSizetext = new GridData(SWT.FILL, SWT.CENTER, true, false);
    volumeSizetext.setLayoutData(gdVolumeSizetext);
    volumeSizetext.setToolTipText(Messages.volumeSizeToolTip);
    /*Initial the volume size*/
    String volumeSize = ConfConstants.DEFAULT_DATA_VOLUME_SIZE;
    String configVolumeSize = CompatibleUtil.getConfigGenericVolumeSize(selection.getServer().getServerInfo(), null);
    if (!StringUtil.isEmpty(configVolumeSize)) {
        Long bytes = StringUtil.getByteNumber(configVolumeSize);
        if (bytes > -1) {
            double value = StringUtil.convertToM(bytes);
            NumberFormat nf = NumberFormat.getInstance();
            nf.setGroupingUsed(false);
            nf.setMaximumFractionDigits(3);
            nf.setMinimumFractionDigits(3);
            volumeSize = nf.format(value);
        }
    }
    volumeSizetext.setText(volumeSize);
    volumeSizetext.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            verify();
        }
    });
    // Sets the initial value
    pathText.setText(getAddVolumeStatusInfo.getVolpath());
    purposeCombo.setText(purpose);
    // Sets listener
    pathText.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent event) {
            verify();
        }
    });
    return parentComp;
}
Also used : Group(org.eclipse.swt.widgets.Group) Composite(org.eclipse.swt.widgets.Composite) ModifyListener(org.eclipse.swt.events.ModifyListener) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text) Combo(org.eclipse.swt.widgets.Combo) GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) DirectoryDialog(org.eclipse.swt.widgets.DirectoryDialog) NumberFormat(java.text.NumberFormat)

Example 30 with DirectoryDialog

use of org.eclipse.swt.widgets.DirectoryDialog in project cubrid-manager by CUBRID.

the class ExportConfigDialog method getSavedDir.

/**
	 * 
	 * Get saved file
	 * 
	 * @param shell Shell
	 * @return File
	 */
private static File getSavedDir(Shell shell) {
    DirectoryDialog dialog = new DirectoryDialog(shell, SWT.SAVE | SWT.APPLICATION_MODAL);
    String filepath = CommonUIPlugin.getSettingValue(EXPORT_FILE_PATH_KEY);
    if (null != filepath) {
        dialog.setFilterPath(filepath);
    }
    String filePath = dialog.open();
    if (filePath == null) {
        return null;
    } else {
        File file = new File(filePath);
        if (file != null) {
            CommonUIPlugin.putSettingValue(EXPORT_FILE_PATH_KEY, file.getParent());
        }
        return file;
    }
}
Also used : File(java.io.File) DirectoryDialog(org.eclipse.swt.widgets.DirectoryDialog)

Aggregations

DirectoryDialog (org.eclipse.swt.widgets.DirectoryDialog)68 SelectionEvent (org.eclipse.swt.events.SelectionEvent)48 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)46 GridData (org.eclipse.swt.layout.GridData)43 Button (org.eclipse.swt.widgets.Button)43 Text (org.eclipse.swt.widgets.Text)43 GridLayout (org.eclipse.swt.layout.GridLayout)42 Composite (org.eclipse.swt.widgets.Composite)38 Label (org.eclipse.swt.widgets.Label)36 Group (org.eclipse.swt.widgets.Group)23 File (java.io.File)21 ModifyEvent (org.eclipse.swt.events.ModifyEvent)21 ModifyListener (org.eclipse.swt.events.ModifyListener)21 Combo (org.eclipse.swt.widgets.Combo)18 TableViewer (org.eclipse.jface.viewers.TableViewer)8 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)7 FileDialog (org.eclipse.swt.widgets.FileDialog)7 Table (org.eclipse.swt.widgets.Table)7 ArrayContentProvider (org.eclipse.jface.viewers.ArrayContentProvider)6 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)6