Example usage for org.eclipse.jface.dialogs IDialogConstants OK_ID

List of usage examples for org.eclipse.jface.dialogs IDialogConstants OK_ID

Introduction

In this page you can find the example usage for org.eclipse.jface.dialogs IDialogConstants OK_ID.

Prototype

int OK_ID

To view the source code for org.eclipse.jface.dialogs IDialogConstants OK_ID.

Click Source Link

Document

Button id for an "Ok" button (value 0).

Usage

From source file:com.astra.ses.spell.gui.shared.views.SharedVariablesView.java

License:Open Source License

/***************************************************************************
 * Complete the creation of the view//from w  w w  . j av a2 s  .  c  om
 **************************************************************************/
@Override
public void createPartControl(Composite parent) {
    setPartName("Shared Variables");

    Composite top = new Composite(parent, SWT.NONE);
    top.setLayout(new GridLayout(3, true));

    m_updateAll = new Button(top, SWT.PUSH);
    m_updateAll.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    m_updateAll.setText("Update all");
    m_updateAll.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent ev) {
            RefreshSharedVariablesJob job = new RefreshSharedVariablesJob();
            CommandHelper.executeInProgress(job, true, true);
            update();
        }
    });

    m_clearAll = new Button(top, SWT.PUSH);
    m_clearAll.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    m_clearAll.setText("Clear all");
    m_clearAll.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent ev) {
            String text = "This action will remove all scopes and variables.\n\nDo you want to proceed?";
            if (MessageDialog.openConfirm(getSite().getShell(), "Delete shared variables", text)) {
                ClearSharedVariablesJob job = new ClearSharedVariablesJob();
                CommandHelper.executeInProgress(job, true, true);
                update();
            }
        }
    });

    m_addScope = new Button(top, SWT.PUSH);
    m_addScope.setText("Add new scope");
    m_addScope.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    m_addScope.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent ev) {
            SharedVariableDialog dialog = new SharedVariableDialog(getSite().getShell());
            if (dialog.open() == IDialogConstants.OK_ID) {
                ISharedDataService svc = (ISharedDataService) ServiceManager.get(ISharedDataService.class);
                svc.addSharedScope(dialog.getScope());
                createScope(dialog.getScope());
            }
        }
    });

    m_tabs = new TabFolder(top, SWT.BORDER);
    GridData tdata = new GridData(GridData.FILL_BOTH);
    tdata.horizontalSpan = 3;
    m_tabs.setLayoutData(tdata);
    m_tabs.setLayout(new GridLayout(1, true));

    IContextProxy proxy = (IContextProxy) ServiceManager.get(IContextProxy.class);
    if (proxy.isConnected()) {
        RefreshSharedVariablesJob job = new RefreshSharedVariablesJob();
        CommandHelper.executeInProgress(job, true, true);
        update();
    }

    proxy.addCommListener(this);
    GuiNotifications.get().addListener(this, ICoreContextOperationListener.class);

    boolean ready = (m_ctxProxy.isConnected() && !m_monitoringMode);
    m_updateAll.setEnabled(m_ctxProxy.isConnected());
    m_addScope.setEnabled(ready);
    m_clearAll.setEnabled(ready);
}

From source file:com.astra.ses.spell.gui.views.controls.master.executors.ExecutorComposite.java

License:Open Source License

/***************************************************************************
 * Button callback/*from  www  . ja  v  a2s . co  m*/
 **************************************************************************/
@Override
public void widgetSelected(SelectionEvent e) {
    if (e.widget instanceof Button) {
        Button button = (Button) e.widget;

        Logger.debug("Button pressed: " + button.getText(), Level.GUI, this);

        String[] procIds = m_executorsTable.getSelectedProcedures();

        disableButtons();

        if (button == m_btnTakeControl) {
            // For later use
            YesNoPromptPref ynp = YesNoPromptPref.valueOf(s_cfg.getProperty(PropertyKey.ASRUN_CONTROL));
            // Find out if we should use ASRUN
            boolean useAsRun = true;
            switch (ynp) {
            case NO:
                useAsRun = false;
                break;
            case PROMPT:
                AttachModeDialog dialog = new AttachModeDialog(getShell());
                if (dialog.open() == IDialogConstants.OK_ID) {
                    useAsRun = dialog.useAsRun();
                }
                // Cancel whole operation 
                else {
                    return;
                }
                break;
            case YES:
                useAsRun = true;
            }
            doTakeControl(procIds, useAsRun);
        } else if (button == m_btnReleaseControl) {
            doReleaseControl(procIds, false);
        } else if (button == m_btnBackground) {
            doReleaseControl(procIds, true);
        } else if (button == m_btnStartMonitor) {
            // For later use
            YesNoPromptPref ynp = YesNoPromptPref.valueOf(s_cfg.getProperty(PropertyKey.ASRUN_MONITOR));
            // Find out if we should use ASRUN
            boolean useAsRun = true;
            switch (ynp) {
            case NO:
                useAsRun = false;
                break;
            case PROMPT:
                AttachModeDialog dialog = new AttachModeDialog(getShell());
                if (dialog.open() == IDialogConstants.OK_ID) {
                    useAsRun = dialog.useAsRun();
                }
                // Cancel whole operation 
                else {
                    return;
                }
                break;
            case YES:
                useAsRun = true;
            }
            doStartMonitor(procIds, useAsRun);
        } else if (button == m_btnStopMonitor) {
            doStopMonitor(procIds);
        } else if (button == m_btnStopExecutor) {
            doStopExecutor(procIds);
        } else if (button == m_btnKillExecutor) {
            doKillExecutor(procIds);
        } else if (button == m_btnRefresh) {
            doRefreshProcedures();
        }
        // Refresh button falls thru here
        refresh();
    }
}

From source file:com.axmor.eclipse.typescript.editor.handlers.OpenTypeHandler.java

License:Open Source License

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    Shell parent = Activator.getDefault().getWorkbench().getActiveWorkbenchWindow().getShell();
    IEditorPart editorPart = Activator.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage()
            .getActiveEditor();// w w  w.  j  ava2 s. co  m
    if (editorPart instanceof TypeScriptEditor) {
        currentTSEditor = (TypeScriptEditor) editorPart;
    }
    currentFile = ((FileEditorInput) editorPart.getEditorInput()).getFile();
    currentProject = currentFile.getProject();
    SelectionDialog dialog = new TypeScriptOpenTypeSelectionDialog(parent, true);
    dialog.setTitle("Open Type");
    dialog.setMessage("Enter type name prefix or pattern (*, ?, or camel case):");

    int result = dialog.open();
    if (result != IDialogConstants.OK_ID) {
        return null;
    }

    Object[] types = dialog.getResult();
    if (types == null || types.length == 0) {
        return null;
    }
    TypeDocument type;
    if (types.length == 1) {
        type = (TypeDocument) types[0];
        openInEditor(type);
        return null;
    }
    for (int i = 0; i < types.length; i++) {
        type = (TypeDocument) types[i];
        openInEditor(type);
    }

    return null;
}

From source file:com.baremetalstudios.mapleide.handlers.NewTextFileDialogHandler.java

License:Open Source License

@Execute
public void openNewTextFileDialog(@Named(IServiceConstants.ACTIVE_SHELL) Shell parentShell,
        @Optional @Named(IServiceConstants.SELECTION) final IResource resource, final IWorkspace workspace,
        IProgressMonitor monitor) {/*ww  w .j av a2  s.co  m*/

    TitleAreaDialog dialog = new TitleAreaDialog(parentShell) {
        private ResourceViewerControl viewer;
        private Text text;

        @Override
        protected Control createDialogArea(Composite parent) {
            Composite comp = (Composite) super.createDialogArea(parent);
            Composite container = new Composite(comp, SWT.NONE);
            container.setLayoutData(new GridData(GridData.FILL_BOTH));
            container.setLayout(new GridLayout(2, false));

            Label label = new Label(container, SWT.NONE);
            label.setText("Folder");

            viewer = new ResourceViewerControl(container, SWT.NONE, workspace, resource);
            viewer.setLayoutData(new GridData(GridData.FILL_BOTH));

            label = new Label(container, SWT.NONE);
            label.setText("File name");

            text = new Text(container, SWT.BORDER);
            text.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

            return comp;
        }

        @Override
        protected void okPressed() {
            IResource resource = viewer.getResource();
            if (resource == null) {
                setMessage("Select a parent folder", IMessageProvider.ERROR);
                return;
            }

            if (text.getText().trim().length() == 0) {
                setMessage("Enter a folder name", IMessageProvider.ERROR);
                return;
            }

            parentContainer = (IContainer) resource;
            name = text.getText();
            super.okPressed();
        }
    };

    if (dialog.open() == IDialogConstants.OK_ID) {
        IPath newFilePath = parentContainer.getFullPath().append(name);
        IFile file = workspace.getRoot().getFile(newFilePath);
        ByteArrayInputStream out = new ByteArrayInputStream(new byte[0]);
        try {
            file.create(out, true, monitor);
        } catch (CoreException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        try {
            out.close();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
}

From source file:com.bdaum.juploadr.uploadapi.smugrest.ui.AlbumPolicyDialog.java

License:Open Source License

private void updateButtons() {
    boolean enabled = !viewer.getSelection().isEmpty();
    getShell().setModified(enabled);
    getButton(IDialogConstants.OK_ID).setEnabled(enabled);
}

From source file:com.bdaum.zoom.gps.internal.dialogs.MapDialog.java

License:Open Source License

@Override
protected void createButtonsForButtonBar(Composite parent) {
    if (current != null)
        super.createButtonsForButtonBar(parent);
    createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
}

From source file:com.bdaum.zoom.lal.internal.lire.ui.dialogs.TextSearchDialog.java

License:Open Source License

private void updateButtons() {
    boolean valid = validate();
    Button okButton = getButton(IDialogConstants.OK_ID);
    if (okButton != null) {
        getShell().setModified(valid);//from   w ww  .  j  a  v a2s.c  o m
        okButton.setEnabled(valid);
    }
}

From source file:com.bdaum.zoom.net.communities.ui.EditCommunityAccountDialog.java

License:Open Source License

private void updateButtons() {
    Button okbutton = getButton(IDialogConstants.OK_ID);
    if (okbutton != null) {
        boolean valid = validate();
        okbutton.setEnabled(valid);//w  ww .  j ava 2 s  .  c  o m
        getShell().setModified(valid);
        if (valid)
            setErrorMessage(null);
    }
}

From source file:com.bdaum.zoom.ui.dialogs.ZInputDialog.java

License:Open Source License

private void updateButtons() {
    boolean enabled = alwaysEnabled || !readonly;
    getShell().setModified(enabled);
    getButton(IDialogConstants.OK_ID).setEnabled(enabled);
}

From source file:com.bdaum.zoom.ui.dialogs.ZInputDialog.java

License:Open Source License

@Override
protected void validateInput() {
    String errorMessage = null;//from  www .  ja  v  a 2s.c  om
    String text = getText().getText();
    if (getValidator() != null)
        errorMessage = getValidator().isValid(text);
    setErrorMessage(errorMessage);
    if (errorMessage == null) {
        setErrorMessage((advisor != null) ? advisor.getAdvice(text) : null);
        getShell().setModified(true);
        getButton(IDialogConstants.OK_ID).setEnabled(true);
    }
}