Example usage for org.eclipse.jface.viewers IStructuredSelection size

List of usage examples for org.eclipse.jface.viewers IStructuredSelection size

Introduction

In this page you can find the example usage for org.eclipse.jface.viewers IStructuredSelection size.

Prototype

public int size();

Source Link

Document

Returns the number of elements selected in this selection.

Usage

From source file:com.jinnova.docaid.parts.PatientSearchPart.java

License:Open Source License

@PostConstruct
public void createComposite(Composite parent) {
    parent.setLayout(new GridLayout(4, false));
    Label label = new Label(parent, SWT.None);
    label.setText(Messages.PatientSearchPart_name);

    nameInput = new Text(parent, SWT.BORDER);
    nameInput.setMessage(Messages.PatientSearchPart_enter_name_id_message);
    //nameInput.addModifyListener(modifyListener);
    GridData gdata = new GridData(GridData.FILL_HORIZONTAL);
    gdata.horizontalSpan = 2;/*from  www  .java  2  s  .  c o m*/
    nameInput.setLayoutData(gdata);
    nameInput.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            search();
        }
    });
    nameInput.addTraverseListener(new TraverseListener() {

        @Override
        public void keyTraversed(TraverseEvent e) {
            if (e.detail == SWT.TRAVERSE_RETURN) {
                search();
            }
        }
    });

    searchButton = new Button(parent, SWT.None);
    searchButton.setText(Messages.PatientSearchPart_search);
    //searchButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL));

    searchButton.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            search();
        }

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {

        }
    });
    /*Button newButton = new Button(parent, SWT.None);
    newButton.setText("Bnh nhn mi");
    newButton.addSelectionListener(new SelectionListener() {
               
       @Override
       public void widgetSelected(SelectionEvent e) {
    selService.setSelection(new Patient());
       }
               
       @Override
       public void widgetDefaultSelected(SelectionEvent e) {
            
       }
    });*/

    patientList = new PatientTableBuilder().builderViewer(parent);

    GridData layoutData = new GridData(GridData.FILL_BOTH);
    layoutData.horizontalSpan = 4;
    patientList.getTable().setLayoutData(layoutData);
    final Table table = patientList.getTable();
    table.setHeaderVisible(true);
    table.setLinesVisible(true);
    patientList.addSelectionChangedListener(new ISelectionChangedListener() {
        public void selectionChanged(SelectionChangedEvent event) {
            //System.out.println("sel changed from search widget");
            //hack selection service to force event always (even with same selection)
            selService.setSelection(new Object());
            IStructuredSelection selection = (IStructuredSelection) event.getSelection();
            // set the selection to the service
            //selService.setSelection(
            //    selection.size() == 1 ? selection.getFirstElement() : selection.toArray());
            Object obj;
            if (selection.size() > 0) {
                obj = selection.getFirstElement();
            } else {
                return;
            }

            if (!familying) {
                selService.setSelection(obj);
            } else {
                selService.setSelection(new PatientFamilyCandidate((Patient) obj));
            }
        }
    });
}

From source file:com.jinnova.docaid.parts.PrescriptionPart.java

License:Open Source License

@PostConstruct
public void createComposite(Composite parent) {
    parent.setLayout(new GridLayout(4, false));

    Color colorBlue = parent.getDisplay().getSystemColor(SWT.COLOR_BLUE);

    Label l = new Label(parent, SWT.None);
    l.setText(Messages.PrescriptionPart_name_colon);
    name = new Label(parent, SWT.None);
    name.setForeground(colorBlue);/*from  w ww.j ava2s. c o m*/
    name.setLayoutData(new GridData(GridData.FILL_HORIZONTAL /*| GridData.GRAB_HORIZONTAL*/));

    l = new Label(parent, SWT.None);
    l.setText(Messages.PrescriptionPart_id_colon);
    idLabel = new Label(parent, SWT.None);
    GridData gdata = new GridData();
    final int secondColWidth = 60;
    gdata.widthHint = secondColWidth;
    idLabel.setLayoutData(gdata);
    idLabel.setForeground(colorBlue);

    l = new Label(parent, SWT.None);
    l.setText(Messages.PrescriptionPart_diagDate_colon);
    diagDate = new Label(parent, SWT.None);
    diagDate.setForeground(colorBlue);
    //diagDate.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    gdata = new GridData(GridData.FILL_HORIZONTAL);
    //gdata.horizontalSpan = 3;
    diagDate.setLayoutData(gdata);

    l = new Label(parent, SWT.None);
    l.setText(Messages.PrescriptionPart_weight_colon);
    weight = new Label(parent, SWT.None);
    weight.setForeground(colorBlue);
    //weight.setText("  50kg  ");
    gdata = new GridData(/*GridData.FILL_HORIZONTAL*/);
    gdata.widthHint = secondColWidth;
    weight.setLayoutData(gdata);

    if (!showPatientDetails) {
        /*new Label(parent, SWT.None);
        new Label(parent, SWT.None);
        l = new Label(parent, SWT.None);
        l.setText("Toa thuc:");
        presCost = new Label(parent, SWT.None);
        presCost.setForeground(colorBlue);
        gdata = new GridData();
        gdata.widthHint = secondColWidth;
        presCost.setLayoutData(gdata);*/
    } else {
        l = new Label(parent, SWT.None);
        l.setText(Messages.PrescriptionPart_histNote_colon);
        healthNote = new Label(parent, SWT.None);
        //healthNote.setForeground(colorBlue);
        //healthNote.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        gdata = new GridData(GridData.FILL_HORIZONTAL);
        gdata.horizontalSpan = 3;
        healthNote.setLayoutData(gdata);
        healthNote.setForeground(colorBlue);

        l = new Label(parent, SWT.None);
        l.setText(Messages.PrescriptionPart_symptoms_colon);
        symptoms = new Label(parent, SWT.None);
        //symptoms.setForeground(colorBlue);
        symptoms.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        gdata = new GridData(GridData.FILL_HORIZONTAL);
        //gdata.horizontalSpan = 3;
        symptoms.setLayoutData(gdata);
        symptoms.setForeground(colorBlue);

        l = new Label(parent, SWT.None);
        l.setText(Messages.PrescriptionPart_services_colon);
        serviceCost = new Label(parent, SWT.None);
        serviceCost.setForeground(colorBlue);
        gdata = new GridData();
        gdata.widthHint = secondColWidth;
        serviceCost.setLayoutData(gdata);

        l = new Label(parent, SWT.None);
        l.setText(Messages.PrescriptionPart_diagBrief_colon);
        diagBrief = new Label(parent, SWT.None);
        //diagBrief.setForeground(colorBlue);
        diagBrief.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        gdata = new GridData(GridData.FILL_HORIZONTAL);
        //gdata.horizontalSpan = 3;
        diagBrief.setLayoutData(gdata);
        diagBrief.setForeground(colorBlue);

        l = new Label(parent, SWT.None);
        l.setText(Messages.PrescriptionPart_prescription_colon);
        presCost = new Label(parent, SWT.None);
        presCost.setForeground(colorBlue);
        gdata = new GridData();
        gdata.widthHint = secondColWidth;
        presCost.setLayoutData(gdata);

        l = new Label(parent, SWT.None);
        l.setText(Messages.PrescriptionPart_treatments_colon);
        treatment = new Label(parent, SWT.None);
        //treatment.setForeground(colorBlue);
        treatment.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        gdata = new GridData(GridData.FILL_HORIZONTAL);
        //gdata.horizontalSpan = 3;
        treatment.setLayoutData(gdata);
        treatment.setForeground(colorBlue);

        l = new Label(parent, SWT.None);
        l.setText(Messages.PrescriptionPart_total_colon);
        totalCost = new Label(parent, SWT.None);
        totalCost.setForeground(colorBlue);
        gdata = new GridData();
        gdata.widthHint = secondColWidth;
        totalCost.setLayoutData(gdata);
    }

    tableViewer = new TableViewer(parent, SWT.V_SCROLL | SWT.H_SCROLL | SWT.FULL_SELECTION);
    tableViewer.setContentProvider(ArrayContentProvider.getInstance());
    gdata = new GridData(GridData.FILL_BOTH);
    gdata.horizontalSpan = 4;
    tableViewer.getTable().setLayoutData(gdata);

    createColumn(30, Messages.PrescriptionPart_queueNumber_abbr, new PrescriptionLabelProvider() {
        @Override
        public String getText(PrescriptionItem p) {
            return String.valueOf(prescription.indexOf(p) + 1);
        }
    });
    createColumn(150, Messages.PrescriptionPart_medName, new PrescriptionLabelProvider() {
        @Override
        public String getText(PrescriptionItem p) {
            return p.medName.getValue();
        }
    });
    createColumn(70, Messages.PrescriptionPart_medDosage, new PrescriptionLabelProvider() {
        @Override
        public String getText(PrescriptionItem p) {
            if (isUndefined(p.amountPerTaking.getValue()) || isUndefined(p.takingCountPerDay.getValue())
                    || p.medUnit == null) {
                return ""; //$NON-NLS-1$
            }
            return p.amountPerTaking.getValue() + " " + p.medUnit + " x " + //$NON-NLS-1$ //$NON-NLS-2$
            p.takingCountPerDay.getValue();
        }
    });
    createColumn(50, Messages.PrescriptionPart_days, new PrescriptionLabelProvider() {
        @Override
        public String getText(PrescriptionItem p) {
            if (isUndefined(p.dayCount.getValue())) {
                return ""; //$NON-NLS-1$
            }
            return p.dayCount.getValue() + Messages.PrescriptionPart_days_spaceprefix;
        }
    });
    createColumn(50, Messages.PrescriptionPart_amount, new ColumnLabelProvider() {
        @Override
        public String getText(Object element) {
            /*if (element instanceof PrescriptionItemExtra) {
               PrescriptionItem pi = (PrescriptionItem) ((PrescriptionItemExtra) element).item;
               return pi.amountTotalUnit + " " + pi.medUnit;
            }
            PrescriptionItem p = (PrescriptionItem) element;
            if (p.amountTotalPackage != null && p.amountTotalPackage != 0) {
               return p.amountTotalPackage + " " + p.medPackage;
            } else if (p.amountTotalUnit != null && p.amountTotalUnit != 0) {
               return p.amountTotalUnit + " " + p.medUnit;
            }
             return "";*/
            if (element instanceof PrescriptionItemExtra) {
                PrescriptionItemExtra extra = (PrescriptionItemExtra) element;
                PrescriptionItem pi = extra.item;
                if (extra.amountPackage) {
                    if (pi.amountTotalPackage == null || pi.amountTotalPackage == 0) {
                        return ""; //$NON-NLS-1$
                    }
                    return pi.amountTotalPackage + " " + pi.medPackage; //$NON-NLS-1$
                } else {
                    if (pi.amountTotalUnit == null || pi.amountTotalUnit == 0) {
                        return ""; //$NON-NLS-1$
                    }
                    return pi.amountTotalUnit + " " + pi.medUnit; //$NON-NLS-1$
                }
            }
            return ""; //$NON-NLS-1$
        }
    });

    TableViewerColumn col = new TableViewerColumn(tableViewer, SWT.RIGHT);
    col.getColumn().setWidth(90);
    col.getColumn().setText(Messages.PrescriptionPart_cost);
    col.setLabelProvider(new ColumnLabelProvider() {
        @Override
        public String getText(Object element) {
            /*if (element instanceof PrescriptionItemExtra) {
               PrescriptionItem pi = (PrescriptionItem) ((PrescriptionItemExtra) element).item;
               if (pi.amountTotalUnit == null || pi.medUnitPrice == null) {
            return "";
               }
               return pi.amountTotalUnit * pi.medUnitPrice + "";
            }
            PrescriptionItem p = (PrescriptionItem) element;
            if (p.amountTotalPackage != null && p.amountTotalPackage != 0) {
               if (p.amountTotalPackage == null || p.medPackagePrice == null) {
            return "";
               }
               return p.amountTotalPackage * p.medPackagePrice + "";
            } else if (p.amountTotalUnit != null && p.amountTotalUnit != 0) {
               if (p.amountTotalUnit == null || p.medUnitPrice == null) {
            return "";
               }
               return p.amountTotalUnit * p.medUnitPrice + "";
            }
             return "";*/
            if (element instanceof PrescriptionItemExtra) {
                PrescriptionItemExtra extra = (PrescriptionItemExtra) element;
                PrescriptionItem pi = extra.item;
                if (extra.amountPackage) {
                    if (pi.amountTotalPackage == null || pi.medPackagePrice == null) {
                        return ""; //$NON-NLS-1$
                    }
                    return pi.amountTotalPackage * pi.medPackagePrice + ""; //$NON-NLS-1$
                } else {
                    if (pi.amountTotalUnit == null || pi.medUnitPrice == null) {
                        return ""; //$NON-NLS-1$
                    }
                    return pi.amountTotalUnit * pi.medUnitPrice + ""; //$NON-NLS-1$
                }
            }

            if (element instanceof Prescription) {
                return ((Prescription) element).computeTotalCost() + ""; //$NON-NLS-1$
            }
            return ""; //$NON-NLS-1$
        }
    });
    createColumn(150, Messages.PrescriptionPart_note, new PrescriptionLabelProvider() {
        @Override
        public String getText(PrescriptionItem p) {
            return p.getNoteReading();
        }
    });

    GridData layoutData = new GridData(GridData.FILL_BOTH);
    layoutData.horizontalSpan = 4;
    tableViewer.getTable().setLayoutData(layoutData);
    final Table table = tableViewer.getTable();
    table.setHeaderVisible(true);
    table.setLinesVisible(true);
    tableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
        public void selectionChanged(SelectionChangedEvent event) {
            IStructuredSelection selection = (IStructuredSelection) event.getSelection();
            if (selection.size() > 0) {
                Object o = selection.getFirstElement();
                PrescriptionItem pi = null;
                if (o instanceof PrescriptionItem) {
                    pi = (PrescriptionItem) o;
                } else if (o instanceof PrescriptionItemExtra) {
                    pi = ((PrescriptionItemExtra) o).item;
                }
                if (pi != null) {
                    pi.prescription.setEditingItem(pi);
                    selService.setSelection(pi);
                }
            }
        }
    });

    if (showPatientDetails /*|| SettingName.isSet(SettingName.diag_skipMedStage.name())*/) {
        doneButton = new Button(parent, SWT.None);
        gdata = new GridData(GridData.FILL_HORIZONTAL);
        gdata.horizontalSpan = 4;
        gdata.heightHint = 40;
        doneButton.setLayoutData(gdata);
        doneButton.setText(Messages.PrescriptionPart_complete);
        doneButton.addSelectionListener(new SelectionListener() {

            @Override
            public void widgetSelected(SelectionEvent e) {

                NamedAction action = getAction();
                if (action != null) {
                    action.run();
                }
            }

            @Override
            public void widgetDefaultSelected(SelectionEvent e) {
            }
        });
    }

    //diagListViewer.setInput(diagList);
    //WaitingList.registerViewer(diagListViewer);
    selService.addSelectionListener(new ISelectionListener() {

        //private DiagRecord newDiag;

        @Override
        public void selectionChanged(MPart part, Object selection) {
            DiagRecord newDiag = null;
            QueueTicket newTicket = null;
            if (selection instanceof QueueTicket) {
                newTicket = (QueueTicket) selection;
                newDiag = newTicket.patient.todayDiag;
            } else if (selection instanceof DiagRecord) {
                newDiag = (DiagRecord) selection;
            } else if (selection instanceof Patient) {
                //newDiag = ((Patient) selection).getOrCreateDirectTicket().diag;
                newDiag = ((Patient) selection).todayDiag;
            }

            if (newDiag == null || newDiag.prescription == prescription) {
                return;
            }

            queueTicket = newTicket;
            prescription = newDiag.prescription;
            populate();
        }
    });

    Patient.addPatientSelectionEmptyListener(new Runnable() {

        @Override
        public void run() {
            queueTicket = null;
            prescription = null;
            populate();
            //tableViewer.setInput(null);
        }
    });

    WaitingList.diagQueue.addQueuePeekingListener(new QueuePeekingListener() {

        @Override
        public void queuePeeked(QueueTicket ticket) {
            queueTicket = ticket;
            if (ticket == null) {
                prescription = null;
            } else {
                prescription = ticket.patient.todayDiag.prescription;
            }
            populate();
        }
    });
    populate();
}

From source file:com.jinnova.docaid.parts.WaitingQueuePart.java

License:Open Source License

@PostConstruct
public void createComposite(Composite parent) {
    parent.setLayout(new GridLayout(1, false));
    patientList = new TableViewer(parent, SWT.V_SCROLL | SWT.H_SCROLL | SWT.FULL_SELECTION);
    patientList.setContentProvider(ArrayContentProvider.getInstance());
    colorHold = parent.getDisplay().getSystemColor(SWT.COLOR_BLUE);
    TableBuilder builder = new TableBuilder();
    builder.createColumn(SettingName.queue_table_field_queuenbr, 30, Messages.WaitingQueuePart_queueNumber_abbr,
            new QueueLabelProvider() {
                @Override//from w  ww .j a  v  a2s. c om
                public String getText(Object element) {
                    QueueTicket p = (QueueTicket) element;
                    String s = p.queueNumber.getValueAsEditing();
                    if (p.isModified()) {
                        return "*" + s; //$NON-NLS-1$
                    } else {
                        return s;
                    }
                }
            });
    builder.createColumn(SettingName.queue_table_field_id, 40, Messages.WaitingQueuePart_id,
            new QueueLabelProvider() {
                @Override
                public String getText(Object element) {
                    QueueTicket p = (QueueTicket) element;
                    return String.valueOf(p.patient.id.getValueAsEditing());
                }
            });
    builder.createColumn(SettingName.queue_table_field_name, 150, Messages.WaitingQueuePart_name,
            new QueueLabelProvider() {
                @Override
                public String getText(Object element) {
                    QueueTicket p = (QueueTicket) element;
                    String name = p.patient.name.getValueAsEditing();
                    if (p.stage == QueueStage.beginHold) {
                        //return name + Messages.WaitingQueuePart_wait_test_in_brackets;
                        return name + " (" + p.getHoldReason() + ")";
                    } else {
                        return name;
                    }
                }
            });
    builder.createColumn(SettingName.queue_table_field_dob, 80, Messages.WaitingQueuePart_dob,
            new QueueLabelProvider() {
                @Override
                public String getText(Object element) {
                    QueueTicket p = (QueueTicket) element;
                    //return p.diag.patient.dob.getValueAsEditing();
                    if (p.patient.dob.isTodayPreviousYear()) {
                        return p.patient.dob.getValueAsEditing()
                                + Messages.WaitingQueuePart_birthday_in_brackets;
                    } else {
                        return p.patient.dob.getValueAsEditing();
                    }
                }
            });
    builder.createColumn(SettingName.queue_table_field_lastvisit, 95, Messages.WaitingQueuePart_last_visit,
            new QueueLabelProvider() {
                @Override
                public String getText(Object element) {
                    QueueTicket p = (QueueTicket) element;
                    //return p.diag.patient.lastVisit.getEasyLabel();
                    return p.previousVisit.getEasyLabel();
                }
            });
    builder.createColumn(SettingName.queue_table_field_prevappoint, 80,
            Messages.WaitingQueuePart_prev_appointment, new QueueLabelProvider() {
                @Override
                public String getText(Object element) {
                    QueueTicket p = (QueueTicket) element;
                    //return p.diag.patient.previousAppointment.getEasyLabel();
                    return p.previousAppointment.getEasyLabel();
                }

                @Override
                public Color getForeground(Object element) {
                    QueueTicket p = (QueueTicket) element;
                    if (p.patient.hasAppointmentToday()) {
                        return parent.getDisplay().getSystemColor(SWT.COLOR_BLUE);
                    }
                    return null;
                }
            });
    builder.createColumn(SettingName.queue_table_field_address, 300, Messages.WaitingQueuePart_address,
            new QueueLabelProvider() {
                @Override
                public String getText(Object element) {
                    QueueTicket p = (QueueTicket) element;
                    return p.patient.address.getValueAsEditing();
                }
            });
    builder.createColumn(SettingName.queue_table_field_age, 50, Messages.WaitingQueuePart_age,
            new QueueLabelProvider() {
                @Override
                public String getText(Object element) {
                    QueueTicket p = (QueueTicket) element;
                    return p.patient.todayDiag.age.getValueAsEditing();
                }
            });
    builder.createColumn(SettingName.queue_table_field_weight, 50, Messages.WaitingQueuePart_weight,
            new QueueLabelProvider() {
                @Override
                public String getText(Object element) {
                    QueueTicket p = (QueueTicket) element;
                    //return FieldFloat.getString(p.patient.todayDiag.weight.getValue());
                    String s = p.patient.todayDiag.weight.getValue();
                    return s == null ? "" : s;
                }
            });
    builder.build(this.patientList);

    GridData layoutData = new GridData(GridData.FILL_BOTH);
    layoutData.horizontalSpan = 4;
    patientList.getTable().setLayoutData(layoutData);
    final Table table = patientList.getTable();
    table.setHeaderVisible(true);
    table.setLinesVisible(true);
    patientList.addSelectionChangedListener(new ISelectionChangedListener() {
        public void selectionChanged(SelectionChangedEvent event) {
            System.out.println("sel changed from widget"); //$NON-NLS-1$
            //hack selection service to force event always (even with same selection)
            selService.setSelection(new Object());
            IStructuredSelection selection = (IStructuredSelection) event.getSelection();
            selService.setSelection(selection.size() == 1 ? selection.getFirstElement() : selection.toArray());
        }
    });

    getWaitingList().registerViewer(patientList);
}

From source file:com.kdmanalytics.toif.report.internal.handlers.SetTrustHandler.java

License:Open Source License

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    final IStructuredSelection ss = (IStructuredSelection) HandlerUtil.getCurrentSelection(event);
    final ReportView view = (ReportView) HandlerUtil.getActivePart(event);
    final Shell shell = HandlerUtil.getActiveShell(event);
    final Integer value = getNewTrustValue(shell);

    IRunnableWithProgress runnable = new IRunnableWithProgress() {

        public void run(IProgressMonitor monitor) {
            if (value != null) {
                List<FindingEntry> entries = new ArrayList<FindingEntry>(ss.size());
                for (Object o : ss.toList()) {
                    if (o instanceof ToifReportEntry) {
                        IToifReportEntry toifReportEntry = (IToifReportEntry) o;
                        if (toifReportEntry.getFindingEntry() != null) {
                            entries.add(toifReportEntry.getFindingEntry());
                        }//  w w w  .  j ava2 s .  c om
                    }
                }
                ModelUtil.setTrustValuesOnFindings(entries, view.getReportInput(), value, monitor);
            }
        }
    };

    try {
        new ProgressMonitorDialog(shell).run(true, false, runnable);
    } catch (InvocationTargetException e) {
        System.err.println("Unable to Set trust values." + e);
    } catch (InterruptedException e) {
        System.err.println("Unable to Set trust values." + e);
    }

    view.refresh();
    return null;
}

From source file:com.legstar.eclipse.plugin.cixscom.popup.actions.AbstractGeneratorAction.java

License:Open Source License

/**
 * @see IActionDelegate#run(IAction)//from www  . j a v a2 s .c  o m
 * @param action
 *            the action proxy that handles presentation portion of the
 *            action; must not be <code>null</code>.
 */
public void run(final IAction action) {
    try {
        /* Get us the selected file */
        IFile file = null;
        if (mSelection != null && !mSelection.isEmpty() && mSelection instanceof IStructuredSelection) {
            IStructuredSelection ssel = (IStructuredSelection) mSelection;
            if (ssel.size() > 1) {
                return;
            }
            Object obj = ssel.getFirstElement();
            if (obj instanceof IResource) {
                if (obj instanceof IFile) {
                    file = (IFile) obj;
                } else {
                    AbstractWizard.throwCoreException(Messages.no_mapping_file_msg);
                }
            }
        }
        startWizard(file);
    } catch (CoreException e) {
        AbstractWizard.logCoreException(e, Activator.PLUGIN_ID);
    }
}

From source file:com.legstar.eclipse.plugin.coxbgen.popup.actions.CoxbGenAction.java

License:Open Source License

/**
 * @see IActionDelegate#run(IAction)/*from  w  w w  .j a  v a  2s  . c om*/
 * @param action
 *            the action proxy that handles presentation portion of the
 *            action; must not be <code>null</code>.
 */
public void run(final IAction action) {
    try {
        /* Get us the selected file */
        IFile file = null;
        if (mSelection != null && !mSelection.isEmpty() && mSelection instanceof IStructuredSelection) {
            IStructuredSelection ssel = (IStructuredSelection) mSelection;
            if (ssel.size() > 1) {
                return;
            }
            Object obj = ssel.getFirstElement();
            if (obj instanceof IResource) {
                if (obj instanceof IFile) {
                    file = (IFile) obj;
                } else {
                    AbstractWizard.throwCoreException(Messages.no_xsd_file_msg);
                }
            }
        }
        CoxbGenWizard wizard = new CoxbGenWizard(file);
        Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
        WizardDialog dialog = new WizardDialog(shell, wizard);
        dialog.setHelpAvailable(false);
        dialog.create();
        dialog.open();
    } catch (CoreException e) {
        AbstractWizard.logCoreException(e, Activator.PLUGIN_ID);
    }
}

From source file:com.liferay.ide.debug.ui.fm.SuspendFreemarkerThreadHandler.java

License:Open Source License

private Object getSelectedElement(Object context) {
    if (context instanceof IEvaluationContext) {
        IEvaluationContext evaluationContext = (IEvaluationContext) context;

        Object currentSelectionVar = evaluationContext.getVariable(ISources.ACTIVE_CURRENT_SELECTION_NAME);

        if (currentSelectionVar instanceof IStructuredSelection) {
            IStructuredSelection selection = (IStructuredSelection) currentSelectionVar;

            if (selection.size() == 1) {
                return selection.getFirstElement();
            }/* w ww  .  j  a va  2 s . c  o  m*/
        }
    }

    return null;
}

From source file:com.liferay.ide.hook.ui.wizard.EventActionsTableWizardSection.java

License:Open Source License

@Override
protected void handleEditButtonSelected() {
    ISelection s = viewer.getSelection();

    if (!(s instanceof IStructuredSelection)) {
        return;/*from  w  w  w  . j  a va 2  s.co m*/
    }

    IStructuredSelection selection = (IStructuredSelection) s;

    if (selection.size() != 1) {
        return;
    }

    Object selectedObj = selection.getFirstElement();
    String[] valuesForText = (String[]) selectedObj;

    EditEventActionDialog dialog = new EditEventActionDialog(getShell(), dialogTitle, fieldLabels,
            valuesForText);
    dialog.open();

    String[] stringArray = dialog.getStringArray();
    editStringArray(valuesForText, stringArray);
}

From source file:com.liferay.ide.hook.ui.wizard.ServicesTableWizardSection.java

License:Open Source License

@Override
protected void handleEditButtonSelected() {
    ISelection s = viewer.getSelection();

    if (!(s instanceof IStructuredSelection)) {
        return;//  ww w . j  av  a2 s . c om
    }

    IStructuredSelection selection = (IStructuredSelection) s;

    if (selection.size() != 1) {
        return;
    }

    Object selectedObj = selection.getFirstElement();
    String[] valuesForText = (String[]) selectedObj;

    EditServiceDialog dialog = new EditServiceDialog(getShell(), dialogTitle, fieldLabels, valuesForText);
    dialog.open();

    String[] stringArray = dialog.getStringArray();
    editStringArray(valuesForText, stringArray);
}

From source file:com.liferay.ide.portlet.ui.editor.PortalDeployExcludesSection.java

License:Open Source License

@SuppressWarnings("rawtypes")
private void handleRemove() {
    IStructuredSelection ssel = (IStructuredSelection) fViewer.getSelection();
    PluginPackageModel model = (PluginPackageModel) getPage().getModel();
    int i = 0;//  ww  w  .  ja  va 2  s .c  om
    String[] removedFiles = new String[ssel.size()];
    for (Iterator iter = ssel.iterator(); iter.hasNext(); i++) {
        removedFiles[i] = ((File) iter.next()).getName();
    }

    model.removePortalDeployExcludeJar(removedFiles);
    updateButtons();
}