Search in sources :

Example 1 with AbstractProjectWizardPage

use of org.eclipse.vorto.wizard.AbstractProjectWizardPage in project vorto by eclipse.

the class AbstractProjectSelectionViewPart method createProjectSelectionViewer.

private ComboViewer createProjectSelectionViewer(final Composite container, String labelStr) {
    Button newProjectButton = new Button(container, SWT.NONE);
    newProjectButton.setImage(ImageUtil.getImage("add_obj.gif"));
    newProjectButton.setToolTipText(getAddToolTipText());
    newProjectButton.addListener(SWT.Selection, new Listener() {

        public void handleEvent(Event e) {
            switch(e.type) {
                case SWT.Selection:
                    WizardDialog wizardDialog = new WizardDialog(container.getShell(), getProjectWizard());
                    if (wizardDialog.open() == Window.OK) {
                        projectSelectionViewer.setInput(getModelProjects());
                        AbstractProjectWizardPage page = (AbstractProjectWizardPage) wizardDialog.getCurrentPage();
                        IModelProject project = getModelProjectFromName(page.getProjName());
                        selectedProject = project;
                        projectSelectionViewer.setSelection(new StructuredSelection(project), true);
                    }
                    break;
                default:
            }
        }
    });
    FormData buttonFormdata = new FormData();
    buttonFormdata.top = new FormAttachment(0, 0);
    buttonFormdata.right = new FormAttachment(100, 0);
    newProjectButton.setLayoutData(buttonFormdata);
    Button deleteButton = new Button(container, SWT.NONE);
    deleteButton.setImage(ImageUtil.getImage("delete.gif"));
    deleteButton.setToolTipText(getDeleteToolTipText());
    deleteButton.addListener(SWT.Selection, new Listener() {

        public void handleEvent(Event e) {
            switch(e.type) {
                case SWT.Selection:
                    if (selectedProject != null) {
                        if (!Display.getDefault().isDisposed()) {
                            Display.getDefault().syncExec(newDeleteProjectRunnable(selectedProject));
                        }
                    }
                    break;
                default:
            }
        }
    });
    FormData deleteButtonFormdata = new FormData();
    deleteButtonFormdata.top = new FormAttachment(0, 0);
    deleteButtonFormdata.right = new FormAttachment(newProjectButton, -10);
    deleteButton.setLayoutData(deleteButtonFormdata);
    ComboViewer comboViewer = new ComboViewer(container, SWT.READ_ONLY);
    Combo combo = comboViewer.getCombo();
    FormData viewerFormData = new FormData();
    viewerFormData.top = new FormAttachment(newProjectButton, 10);
    viewerFormData.left = new FormAttachment(0, 0);
    viewerFormData.right = new FormAttachment(100, 0);
    combo.setLayoutData(viewerFormData);
    Label label = new Label(container, SWT.NONE);
    label.setText(labelStr);
    FormData labelFormData = new FormData();
    labelFormData.bottom = new FormAttachment(comboViewer.getCombo(), -10);
    labelFormData.left = new FormAttachment(0, 0);
    label.setLayoutData(labelFormData);
    return comboViewer;
}
Also used : FormData(org.eclipse.swt.layout.FormData) RemoveModelListener(org.eclipse.vorto.perspective.listener.RemoveModelListener) ErrorDiagnosticListener(org.eclipse.vorto.perspective.listener.ErrorDiagnosticListener) IResourceChangeListener(org.eclipse.core.resources.IResourceChangeListener) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) RemoveModelProjectListener(org.eclipse.vorto.perspective.listener.RemoveModelProjectListener) Listener(org.eclipse.swt.widgets.Listener) RemoveImportListener(org.eclipse.vorto.perspective.listener.RemoveImportListener) AbstractProjectWizardPage(org.eclipse.vorto.wizard.AbstractProjectWizardPage) Button(org.eclipse.swt.widgets.Button) IModelProject(org.eclipse.vorto.core.ui.model.IModelProject) ComboViewer(org.eclipse.jface.viewers.ComboViewer) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) Label(org.eclipse.swt.widgets.Label) IResourceChangeEvent(org.eclipse.core.resources.IResourceChangeEvent) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) Event(org.eclipse.swt.widgets.Event) Combo(org.eclipse.swt.widgets.Combo) WizardDialog(org.eclipse.jface.wizard.WizardDialog) FormAttachment(org.eclipse.swt.layout.FormAttachment)

Aggregations

IResourceChangeEvent (org.eclipse.core.resources.IResourceChangeEvent)1 IResourceChangeListener (org.eclipse.core.resources.IResourceChangeListener)1 ComboViewer (org.eclipse.jface.viewers.ComboViewer)1 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)1 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)1 WizardDialog (org.eclipse.jface.wizard.WizardDialog)1 FormAttachment (org.eclipse.swt.layout.FormAttachment)1 FormData (org.eclipse.swt.layout.FormData)1 Button (org.eclipse.swt.widgets.Button)1 Combo (org.eclipse.swt.widgets.Combo)1 Event (org.eclipse.swt.widgets.Event)1 Label (org.eclipse.swt.widgets.Label)1 Listener (org.eclipse.swt.widgets.Listener)1 IModelProject (org.eclipse.vorto.core.ui.model.IModelProject)1 ErrorDiagnosticListener (org.eclipse.vorto.perspective.listener.ErrorDiagnosticListener)1 RemoveImportListener (org.eclipse.vorto.perspective.listener.RemoveImportListener)1 RemoveModelListener (org.eclipse.vorto.perspective.listener.RemoveModelListener)1 RemoveModelProjectListener (org.eclipse.vorto.perspective.listener.RemoveModelProjectListener)1