Example usage for org.apache.wicket.ajax AjaxSelfUpdatingTimerBehavior AjaxSelfUpdatingTimerBehavior

List of usage examples for org.apache.wicket.ajax AjaxSelfUpdatingTimerBehavior AjaxSelfUpdatingTimerBehavior

Introduction

In this page you can find the example usage for org.apache.wicket.ajax AjaxSelfUpdatingTimerBehavior AjaxSelfUpdatingTimerBehavior.

Prototype

public AjaxSelfUpdatingTimerBehavior(final Duration updateInterval) 

Source Link

Document

Construct.

Usage

From source file:abid.password.wicket.pages.LoginPage.java

License:Apache License

public LoginPage() {
    LoginPanel loginPanel = new LoginPanel("loginPanel");
    add(loginPanel);/*from  w ww .j  av  a 2s . c  om*/

    LoadableDetachableModel<List<User>> usersModel = new LoadableDetachableModel<List<User>>() {

        private static final long serialVersionUID = 1L;

        @Override
        protected List<User> load() {
            return userService.getUsers();
        }
    };

    PageableListView<User> dataList = new PageableListView<User>("usersList", usersModel, 100) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(ListItem<User> item) {
            final User data = item.getModelObject();
            Label userLabel = new Label("userLabel", data.getUsername());
            Label passLabel = new Label("passLabel", data.getPassword());

            try {
                Password password = new MutablePasswordParser().parse(data.getPassword());
                if (password instanceof MutablePassword) {
                    MutablePassword mutablePassword = (MutablePassword) password;
                    String evalatedPassword = mutablePassword.getEvaluatedPassword();
                    passLabel = new Label("passLabel", evalatedPassword);
                }
            } catch (Exception e) {
                log.error("Could not create the mutable password", e);
            }

            item.add(userLabel);
            item.add(passLabel);
        }
    };

    int refreshTime = 3;
    final WebMarkupContainer usersContainer = new WebMarkupContainer("usersContainer");
    usersContainer.setOutputMarkupId(true);
    usersContainer.add(new AjaxSelfUpdatingTimerBehavior(Duration.seconds(refreshTime)));
    usersContainer.add(dataList);

    String refreshInformation = String.format("Password refreshes every %s seconds.", refreshTime);
    String javascriptDisabledMsg = "Javascript is disabled you will need to refresh the page manually.";
    AjaxFallbackLabel refreshLabel = new AjaxFallbackLabel("refreshInformation", refreshInformation,
            javascriptDisabledMsg);

    add(usersContainer);
    add(refreshLabel);
}

From source file:abid.password.wicket.pages.UsersPage.java

License:Apache License

public UsersPage() {

    LoadableDetachableModel<List<User>> usersModel = new LoadableDetachableModel<List<User>>() {

        private static final long serialVersionUID = 1L;

        @Override//w  ww. j  a  v a2  s.co  m
        protected List<User> load() {
            return userService.getUsers();
        }
    };

    PageableListView<User> dataList = new PageableListView<User>("usersList", usersModel, 100) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(ListItem<User> item) {
            final User data = item.getModelObject();
            Label userLabel = new Label("userLabel", data.getUsername());
            Label passLabel = new Label("passLabel", data.getPassword());

            try {
                Password password = new MutablePasswordParser().parse(data.getPassword());
                if (password instanceof MutablePassword) {
                    MutablePassword mutablePassword = (MutablePassword) password;
                    String evalatedPassword = mutablePassword.getEvaluatedPassword();
                    passLabel = new Label("passLabel", evalatedPassword);
                }
            } catch (Exception e) {
                log.error("Could not create the mutable password", e);
            }

            item.add(userLabel);
            item.add(passLabel);
        }
    };

    int refreshTime = 3;
    final WebMarkupContainer dataContainer = new WebMarkupContainer("dataContainer");
    dataContainer.setOutputMarkupId(true);
    dataContainer.add(new AjaxSelfUpdatingTimerBehavior(Duration.seconds(refreshTime)));
    dataContainer.add(dataList);

    String refreshInformation = String.format("Password refreshes every %s seconds.", refreshTime);
    String javascriptDisabledMsg = "Javascript is disabled you will need to refresh the page manually.";
    AjaxFallbackLabel refreshInfoLabel = new AjaxFallbackLabel("refreshInformation", refreshInformation,
            javascriptDisabledMsg);

    add(dataContainer);
    add(refreshInfoLabel);
}

From source file:at.ac.tuwien.ifs.tita.ui.tasklist.stopwatch.AssignedTaskTimerPanel.java

License:Apache License

/**
 * Displays the Panel with all wicket elements.
 *///  ww w. j  av  a 2s.  c o  m
private void displayPanel() {
    taskTimerForm = new Form<Object>("timerTaskForm");
    add(taskTimerForm);

    taskTimerForm.add(new Label("taskId", task.getId().toString()));
    taskTimerForm.add(new Label("taskDescription", task.getDescription()));
    startstop = new AjaxButton("startStopTimer", new Model<String>(), taskTimerForm) {
        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form1) {

            if (!started) {
                owner.startTimerForIssue(task);
                started = true;
                this.getModel().setObject("Stop");
            } else {
                owner.stopTimerForIssue(task, target);
                started = false;
                this.getModel().setObject("Start");
            }
            this.setLabel(this.getModel());
            target.addComponent(this);
        }
    };
    taskTimerForm.add(startstop);
    taskTimerForm.add(new AjaxButton("closeTask", taskTimerForm) {
        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form1) {
            started = false;
            // beh.stop();
            owner.stopTimerForIssue(task, target);
            owner.closeTask(task, target);
        }
    });
    lab = new Label("totalEffort", TiTATimeConverter.getDuration2String(effort != null ? effort : 0L));
    taskTimerForm.add(lab);
    beh = new AjaxSelfUpdatingTimerBehavior(Duration.seconds(1));
    lab.add(beh);
}

From source file:at.ac.tuwien.ifs.tita.ui.tasklist.stopwatch.GeneralTimerPanel.java

License:Apache License

/**
 * Displays the Panel with all wicket elements.
 *///from   w w  w . ja  v  a  2 s.com
private void displayPanel() {
    taskTimerForm = new Form<Object>("timerTaskForm");
    add(taskTimerForm);
    taskTimerForm.add(new Label("taskLabel", "Description"));
    description = new TextField<String>("taskDescription", new Model<String>(""));
    description.setType(String.class);

    duration = new TextField<String>("taskDuration", new Model<String>("00:00:00"));
    duration.setType(String.class);
    duration.add(new AjaxSelfUpdatingTimerBehavior(Duration.seconds(1)));
    duration.setOutputMarkupId(true);
    description.setOutputMarkupId(true);

    taskTimerForm.add(duration);
    taskTimerForm.add(description);

    startstop = new AjaxButton("startStopTimer", new Model<String>(), taskTimerForm) {
        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form1) {
            if (!started) {
                owner.startGeneralTimerForTask();
                description.getModel().setObject("");
                started = true;
                this.getModel().setObject("Stop");
            } else {
                owner.stopGeneralTimerForTask();
                started = false;
                this.getModel().setObject("Start");
            }

            this.setLabel(this.getModel());
            target.addComponent(this);
        }
    };
    taskTimerForm.add(startstop);
    taskTimerForm.add(new AjaxButton("saveEffort", taskTimerForm) {
        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form1) {
            if (effort != null && !started) {
                owner.saveEffortForTiTATask(effort, target);
                description.setModelObject("");
                duration.setModelObject("00:00:00");
            }
            target.addComponent(description);
            target.addComponent(duration);
        }
    });
}

From source file:com.axway.ats.testexplorer.pages.model.BaseCopyPage.java

License:Apache License

private void startCurrentCopyThread() {

    // start the timer
    consoleUpdateTimer = new AjaxSelfUpdatingTimerBehavior(Duration.seconds(CONSOLE_UPDATE_INTERVAL));
    consoleContainer.add(consoleUpdateTimer);
    // adding console update timer to thread and when the coping is done the timer will be stopped
    copyThread.addConsoleUpdateTimer(consoleUpdateTimer);

    copyThread.start();//w w  w.  ja v  a 2 s  .co m

    synchronized (copyJobThreads) {

        copyJobThreads.add(copyThread);
    }

}

From source file:com.axway.ats.testexplorer.pages.model.BaseCopyPage.java

License:Apache License

private boolean checkForThreadCopingTheSameRun(String threadIdentifier) {

    synchronized (copyJobThreads) {

        for (CopyJobThread th : copyJobThreads) {
            if (th.isAlive() && th.getThreadIdentifier().equals(threadIdentifier)) {

                webConsole = th.getWebConsole();
                // start the timer and attach it to the coping thread
                AjaxSelfUpdatingTimerBehavior consoleUpdateTimer = new AjaxSelfUpdatingTimerBehavior(
                        Duration.seconds(CONSOLE_UPDATE_INTERVAL));
                th.addConsoleUpdateTimer(consoleUpdateTimer);
                consoleContainer.add(consoleUpdateTimer);
                return true;
            }/*from  w  w  w.  j ava  2  s. c o  m*/
        }
    }
    return false;
}

From source file:com.comcast.cdn.traffic_control.traffic_monitor.wicket.components.EventLogPanel.java

License:Apache License

public EventLogPanel(final String id) {
    super(id);//w  w w. j  a va2  s  . com

    final IModel<ArrayList<JSONObject>> listModel = new Model<ArrayList<JSONObject>>() {
        private static final long serialVersionUID = 1L;

        @Override
        @SuppressWarnings("PMD")
        public ArrayList<JSONObject> getObject() {
            return new ArrayList<JSONObject>(Event.getEventLog());
        }
    };
    final ListView<JSONObject> propView2 = new ListView<JSONObject>("events", listModel) {
        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(final ListItem<JSONObject> item) {
            final JSONObject jo = item.getModelObject();
            String errorClass = "";
            try {
                item.add(new Label("index", Long.toString(jo.getLong("index"))));
                //               long time = System.currentTimeMillis();
                long time = jo.getLong("time");
                synchronized (formatter) {
                    item.add(new Label("time", formatter.format(new Date(time))));
                }
                item.add(new Label("timeraw", Long.toString(jo.getLong("time"))));
                item.add(new Label("description", jo.getString("description")));
                item.add(new Label("hostname", jo.getString("hostname")));
                String status = "available";
                if (!jo.getBoolean("isAvailable")) {
                    status = "offline";
                    errorClass = "error";
                }
                item.add(new Label("status", status));
            } catch (JSONException e) {
                LOGGER.warn(e, e);
            }
            item.add(new UpdatingAttributeAppender("class", new Model<String>(errorClass), " "));

        }
    };
    this.add(new AjaxSelfUpdatingTimerBehavior(Duration.seconds(5)));

    add(propView2);
}

From source file:com.comcast.cdn.traffic_control.traffic_monitor.wicket.components.StatusPanel.java

License:Apache License

public StatusPanel(final String id) {
    super(id);/*from  w  w  w  .  j  a v a 2s .  co  m*/
    final WebMarkupContainer c = new WebMarkupContainer("container");
    add(c);

    //      final Model<String> count = new Model<String>("0");
    c.add(new Clock("clock", TimeZone.getTimeZone("America/Denver")));
    c.add(new AjaxSelfUpdatingTimerBehavior(Duration.seconds(1)));

    final ListView<Model<String>> props = new ListView<Model<String>>("props", CacheWatcher.getProps()) {
        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(final ListItem<Model<String>> item) {
            final Model<String> val = item.getModelObject();
            item.add(new Label("value", val));
        }
    };
    c.add(props);

    final JSONObject stats = Stats.getVersionInfo().optJSONObject("stats");
    final String[] keys = (stats == null || stats.length() == 0) ? new String[0] : JSONObject.getNames(stats);
    final ListView<String> props2 = new ListView<String>("versionInfo", Arrays.asList(keys)) {
        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(final ListItem<String> item) {
            final String key = item.getModelObject();
            item.add(new Label("key", key));
            item.add(new Label("value", new Model<String>() {
                private static final long serialVersionUID = 1L;

                @Override
                public String getObject() {
                    JSONObject stats = Stats.getVersionInfo().optJSONObject("stats");
                    return stats.optString(key);
                }
            }));
        }
    };
    c.add(props2);
}

From source file:com.doculibre.constellio.wicket.components.form.LoggingTextArea.java

License:Open Source License

private void initComponents(long refreshDelayMillis) {
    add(new AjaxSelfUpdatingTimerBehavior(Duration.milliseconds(refreshDelayMillis)));
    add(new SimpleAttributeModifier("readonly", "readonly"));
}

From source file:com.doculibre.constellio.wicket.panels.admin.indexing.AdminIndexingPanel.java

License:Open Source License

public AdminIndexingPanel(String id) {
    super(id);//from   w  ww . ja v  a  2 s . c  o  m
    sizeDisk = 0;
    indexedRecords = 0;

    add(new AjaxSelfUpdatingTimerBehavior(Duration.ONE_SECOND));
    // add(new AbstractAjaxTimerBehavior(Duration.ONE_SECOND) {
    // @Override
    // protected void onTimer(AjaxRequestTarget target) {
    // // Do nothing, will prevent page from expiring
    // }
    // });

    connectorsModel = new LoadableDetachableModel() {
        @Override
        protected Object load() {
            List<ConnectorInstance> connectors;
            RecordCollection collection = getRecordCollection();
            if (collection.isFederationOwner()) {
                FederationServices federationServices = ConstellioSpringUtils.getFederationServices();
                connectors = federationServices.listConnectors(collection);
            } else {
                connectors = new ArrayList<ConnectorInstance>(collection.getConnectorInstances());
            }
            return connectors;
        }
    };

    manageConnectorsLink = new Link("manageConnectorsLink") {
        @Override
        public void onClick() {
            AdminCollectionPanel adminCollectionPanel = (AdminCollectionPanel) findParent(
                    AdminCollectionPanel.class);
            adminCollectionPanel.setSelectedTab(AdminCollectionPanel.CONNECTORS_MANAGEMENT_PANEL);
        }

        @Override
        public boolean isVisible() {
            boolean visible = super.isVisible();
            if (visible) {
                RecordCollection collection = getRecordCollection();
                visible = collection.getConnectorInstances().isEmpty();
            }
            return visible;
        }
    };

    synchronizeIndexFieldsLink = new Link("synchronizeIndexFieldsLink") {
        @Override
        public void onClick() {
            RecordCollection collection = getRecordCollection();

            RecordCollectionServices collectionServices = ConstellioSpringUtils.getRecordCollectionServices();
            SolrServices solrServices = ConstellioSpringUtils.getSolrServices();

            solrServices.updateSchemaFields(collection);
            solrServices.initCore(collection);

            EntityManager entityManager = ConstellioPersistenceContext.getCurrentEntityManager();
            if (!entityManager.getTransaction().isActive()) {
                entityManager.getTransaction().begin();
            }
            collectionServices.markSynchronized(collection);
            entityManager.getTransaction().commit();

            IndexingManager indexingManager = IndexingManager.get(collection);
            if (!indexingManager.isActive()) {
                indexingManager.startIndexing();
            }
        }

        @Override
        public boolean isVisible() {
            boolean visible = super.isVisible();
            if (visible) {
                RecordCollection collection = getRecordCollection();
                visible = collection.isSynchronizationRequired();
            }
            return visible;
        }
    };

    manageIndexFieldsLink = new Link("manageIndexFieldsLink") {
        @Override
        public void onClick() {
            AdminCollectionPanel adminCollectionPanel = (AdminCollectionPanel) findParent(
                    AdminCollectionPanel.class);
            adminCollectionPanel.setSelectedTab(AdminCollectionPanel.INDEX_FIELDS_MANAGEMENT_PANEL);
        }
    };

    recordCountLabel = new Label("recordCount", new LoadableDetachableModel() {
        @Override
        protected Object load() {
            RecordCollection collection = getRecordCollection();
            return StatusManager.countTraversedRecords(collection);
        }
    });

    deleteAllLink = new Link("deleteAllLink") {
        @Override
        public void onClick() {
            RecordCollection collection = getRecordCollection();
            RecordServices recordServices = ConstellioSpringUtils.getRecordServices();
            FederationServices federationServices = ConstellioSpringUtils.getFederationServices();

            ReadWriteLock collectionLock = recordServices.getLock(collection.getName());
            collectionLock.writeLock().lock();
            try {

                ConstellioPersistenceUtils.beginTransaction();
                recordServices.markRecordsForDeletion(collection);
                if (collection.isFederationOwner()) {
                    List<RecordCollection> includedCollections = federationServices
                            .listIncludedCollections(collection);
                    for (RecordCollection includedCollection : includedCollections) {
                        recordServices.markRecordsForDeletion(includedCollection);
                    }
                }
                SolrServer solrServer = SolrCoreContext.getSolrServer(collection);
                try {
                    solrServer.commit();
                    solrServer.optimize();
                } catch (Throwable t) {
                    try {
                        solrServer.rollback();
                    } catch (Exception e) {
                        throw new RuntimeException(t);
                    }
                }
            } finally {
                try {
                    ConstellioPersistenceUtils.finishTransaction(false);
                } finally {
                    collectionLock.writeLock().unlock();
                }
            }

            // RecordCollection collection = getRecordCollection();
            //
            // ConnectorManagerServices connectorManagerServices =
            // ConstellioSpringUtils.getConnectorManagerServices();
            // ConnectorManager connectorManager =
            // connectorManagerServices.getDefaultConnectorManager();
            // for (ConnectorInstance connectorInstance :
            // collection.getConnectorInstances()) {
            // String connectorName = connectorInstance.getName();
            // connectorManagerServices.disableConnector(connectorManager,
            // connectorName);
            // }
            //
            // IndexingManager indexingManager =
            // IndexingManager.get(collection);
            // indexingManager.deleteAll();
            // indexingManager.optimize();
            // while (indexingManager.isOptimizing()) {
            // try {
            // Thread.sleep(200);
            // } catch (InterruptedException e) {
            // e.printStackTrace();
            // }
            // }
        }

        @Override
        protected CharSequence getOnClickScript(CharSequence url) {
            String confirmMsg = getLocalizer().getString("confirmDeleteAll", AdminIndexingPanel.this)
                    .replace("'", "\\'");
            return "if (confirm('" + confirmMsg + "')) { window.location.href='" + url
                    + "';} else { return false; }";
        }
    };

    indexedRecordCountLabel = new Label("indexedRecordCount", new LoadableDetachableModel() {
        @Override
        protected Object load() {
            RecordCollection collection = getRecordCollection();
            return StatusManager.countIndexedRecords(collection);
        }
    });

    controlIndexingButtons = new WebMarkupContainer("controlIndexingButtons");
    controlIndexingButtons.setOutputMarkupId(true);

    reindexAllLink = new Link("reindexAllLink") {
        @Override
        public void onClick() {
            RecordCollection collection = getRecordCollection();
            final String collectioName = collection.getName();
            final Long collectionId = collection.getId();

            new Thread() {
                @Override
                public void run() {
                    RecordServices recordServices = ConstellioSpringUtils.getRecordServices();
                    ReadWriteLock collectionLock = recordServices.getLock(collectioName);
                    collectionLock.writeLock().lock();
                    try {
                        EntityManager entityManager = ConstellioPersistenceContext.getCurrentEntityManager();
                        if (!entityManager.getTransaction().isActive()) {
                            entityManager.getTransaction().begin();
                        }

                        RecordCollectionServices collectionServices = ConstellioSpringUtils
                                .getRecordCollectionServices();
                        FederationServices federationServices = ConstellioSpringUtils.getFederationServices();
                        RecordCollection collection = collectionServices.get(collectionId);
                        try {
                            recordServices.markRecordsForUpdateIndex(collection);
                            if (collection.isFederationOwner()) {
                                List<RecordCollection> includedCollections = federationServices
                                        .listIncludedCollections(collection);
                                for (RecordCollection includedCollection : includedCollections) {
                                    recordServices.markRecordsForUpdateIndex(includedCollection);
                                }
                            }
                            SolrServer solrServer = SolrCoreContext.getSolrServer(collection);
                            try {
                                // solrServer.commit();
                                solrServer.optimize();
                            } catch (Throwable t) {
                                try {
                                    solrServer.rollback();
                                } catch (Exception e) {
                                    throw new RuntimeException(t);
                                }
                            }
                        } finally {
                            ConstellioPersistenceUtils.finishTransaction(false);
                        }
                    } finally {
                        collectionLock.writeLock().unlock();
                    }
                }

            }.start();
        }

        @Override
        protected CharSequence getOnClickScript(CharSequence url) {
            String confirmMsg = getLocalizer().getString("confirmReindexAll", AdminIndexingPanel.this)
                    .replace("'", "\\'");
            return "if (confirm('" + confirmMsg + "')) { window.location.href='" + url
                    + "';} else { return false; }";
        }
    };

    resumeIndexingLink = new Link("resumeIndexingLink") {
        @Override
        public void onClick() {
            RecordCollection collection = getRecordCollection();
            IndexingManager indexingManager = IndexingManager.get(collection);
            if (!indexingManager.isActive()) {
                indexingManager.startIndexing(false);
            }
        }

        @Override
        public boolean isVisible() {
            // boolean visible = super.isVisible();
            // if (visible) {
            // RecordCollection collection = getRecordCollection();
            // IndexingManager indexingManager =
            // IndexingManager.get(collection);
            // visible = !collection.isSynchronizationRequired() &&
            // !indexingManager.isActive();
            // }
            // return visible;
            return false;
        }
    };

    optimizeLink = new Link("optimizeLink") {
        @Override
        public void onClick() {
            RecordCollection collection = getRecordCollection();
            final Long collectionId = collection.getId();
            new Thread() {
                @Override
                public void run() {
                    RecordCollectionServices collectionServices = ConstellioSpringUtils
                            .getRecordCollectionServices();
                    RecordCollection collection = collectionServices.get(collectionId);
                    SolrServer solrServer = SolrCoreContext.getSolrServer(collection);
                    try {
                        solrServer.optimize();
                    } catch (Throwable t) {
                        try {
                            solrServer.rollback();
                        } catch (Exception e) {
                            throw new RuntimeException(t);
                        }
                    }
                    // IndexingManager indexingManager =
                    // IndexingManager.get(collection);
                    // if (indexingManager.isActive() &&
                    // !indexingManager.isOptimizing()) {
                    // indexingManager.optimize();
                    // }
                }
            }.start();
        }

        @Override
        protected CharSequence getOnClickScript(CharSequence url) {
            String confirmMsg = getLocalizer().getString("confirmOptimize", AdminIndexingPanel.this)
                    .replace("'", "\\'");
            return "if (confirm('" + confirmMsg + "')) { window.location.href='" + url
                    + "';} else { return false; }";
        }

        @Override
        public boolean isVisible() {
            // boolean visible = super.isVisible();
            // if (visible) {
            // RecordCollection collection = getRecordCollection();
            // IndexingManager indexingManager =
            // IndexingManager.get(collection);
            // visible = indexingManager.isActive();
            // }
            // return visible;
            return true;
        }

        @Override
        public boolean isEnabled() {
            // boolean enabled = super.isEnabled();
            // if (enabled) {
            // RecordCollection collection = getRecordCollection();
            // IndexingManager indexingManager =
            // IndexingManager.get(collection);
            // enabled = indexingManager.isActive() &&
            // !indexingManager.isOptimizing();
            // }
            // return enabled;
            return true;
        }
    };

    indexSizeOnDiskLabel = new Label("indexSizeOnDisk", new LoadableDetachableModel() {
        @Override
        protected Object load() {
            RecordCollection collection = getRecordCollection();
            return StatusManager.getSizeOnDisk(collection);
        }
    });

    connectorTraversalStatesListView = new ListView("connectorTraversalStates", connectorsModel) {
        @Override
        protected void populateItem(ListItem item) {
            ConnectorInstance connectorInstance = (ConnectorInstance) item.getModelObject();
            final ReloadableEntityModel<ConnectorInstance> connectorInstanceModel = new ReloadableEntityModel<ConnectorInstance>(
                    connectorInstance);
            Label displayNameLabel = new Label("displayName", connectorInstance.getDisplayName());
            Label lastTraversalDateLabel = new Label("latestTraversalDate", new LoadableDetachableModel() {
                @Override
                protected Object load() {
                    ConnectorInstance connectorInstance = connectorInstanceModel.getObject();
                    Date lastTraversalDate = StatusManager.getLastTraversalDate(connectorInstance);
                    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                    return lastTraversalDate != null ? sdf.format(lastTraversalDate) : "---";
                }

                @Override
                public void detach() {
                    connectorInstanceModel.detach();
                    super.detach();
                }
            });

            Link restartTraversalLink = new Link("restartTraversalLink") {
                @Override
                public void onClick() {
                    ConnectorInstance connectorInstance = connectorInstanceModel.getObject();
                    ConnectorManagerServices connectorManagerServices = ConstellioSpringUtils
                            .getConnectorManagerServices();
                    ConnectorManager connectorManager = connectorManagerServices.getDefaultConnectorManager();
                    connectorManagerServices.restartTraversal(connectorManager, connectorInstance.getName());
                }

                @Override
                protected CharSequence getOnClickScript(CharSequence url) {
                    String confirmMsg = getLocalizer()
                            .getString("confirmRestartTraversal", AdminIndexingPanel.this).replace("'", "\\'");
                    return "if (confirm('" + confirmMsg + "')) { window.location.href='" + url
                            + "';} else { return false; }";
                }

                @Override
                public boolean isVisible() {
                    ConnectorInstance connectorInstance = connectorInstanceModel.getObject();
                    RecordCollection connectorInstanceCollection = connectorInstance.getRecordCollection();
                    ConstellioUser user = ConstellioSession.get().getUser();
                    return super.isVisible() && user.hasAdminPermission(connectorInstanceCollection);
                }
            };

            Link disableConnectorLink = new Link("disableConnectorLink") {
                @Override
                public void onClick() {
                    ConnectorInstance connectorInstance = connectorInstanceModel.getObject();
                    String connectorName = connectorInstance.getName();
                    ConnectorManagerServices connectorManagerServices = ConstellioSpringUtils
                            .getConnectorManagerServices();
                    ConnectorManager connectorManager = connectorManagerServices.getDefaultConnectorManager();
                    connectorManagerServices.disableConnector(connectorManager, connectorName);
                }

                @Override
                protected CharSequence getOnClickScript(CharSequence url) {
                    String confirmMsg = getLocalizer()
                            .getString("confirmDisableConnector", AdminIndexingPanel.this).replace("'", "\\'");
                    return "if (confirm('" + confirmMsg + "')) { window.location.href='" + url
                            + "';} else { return false; }";
                }

                @Override
                public boolean isVisible() {
                    boolean visible = super.isVisible();
                    if (visible) {
                        ConnectorInstance connectorInstance = connectorInstanceModel.getObject();
                        String connectorName = connectorInstance.getName();
                        ConnectorManagerServices connectorManagerServices = ConstellioSpringUtils
                                .getConnectorManagerServices();
                        ConnectorManager connectorManager = connectorManagerServices
                                .getDefaultConnectorManager();
                        visible = connectorManagerServices.isConnectorEnabled(connectorManager, connectorName);
                        if (visible) {
                            RecordCollection connectorInstanceCollection = connectorInstance
                                    .getRecordCollection();
                            ConstellioUser user = ConstellioSession.get().getUser();
                            visible = user.hasAdminPermission(connectorInstanceCollection);
                        }
                    }
                    return visible;
                }
            };

            Link enableConnectorLink = new Link("enableConnectorLink") {
                @Override
                public void onClick() {
                    ConnectorInstance connectorInstance = connectorInstanceModel.getObject();
                    String connectorName = connectorInstance.getName();
                    ConnectorManagerServices connectorManagerServices = ConstellioSpringUtils
                            .getConnectorManagerServices();
                    ConnectorManager connectorManager = connectorManagerServices.getDefaultConnectorManager();
                    connectorManagerServices.enableConnector(connectorManager, connectorName);
                }

                @Override
                protected CharSequence getOnClickScript(CharSequence url) {
                    String confirmMsg = getLocalizer()
                            .getString("confirmEnableConnector", AdminIndexingPanel.this).replace("'", "\\'");
                    return "if (confirm('" + confirmMsg + "')) { window.location.href='" + url
                            + "';} else { return false; }";
                }

                @Override
                public boolean isVisible() {
                    boolean visible = super.isVisible();
                    if (visible) {
                        ConnectorInstance connectorInstance = connectorInstanceModel.getObject();
                        String connectorName = connectorInstance.getName();
                        ConnectorManagerServices connectorManagerServices = ConstellioSpringUtils
                                .getConnectorManagerServices();
                        ConnectorManager connectorManager = connectorManagerServices
                                .getDefaultConnectorManager();
                        visible = !connectorManagerServices.isConnectorEnabled(connectorManager, connectorName);
                        if (visible) {
                            RecordCollection connectorInstanceCollection = connectorInstance
                                    .getRecordCollection();
                            ConstellioUser user = ConstellioSession.get().getUser();
                            visible = user.hasAdminPermission(connectorInstanceCollection);
                        }
                    }
                    return visible;
                }
            };

            item.add(displayNameLabel);
            item.add(lastTraversalDateLabel);
            item.add(restartTraversalLink);
            item.add(disableConnectorLink);
            item.add(enableConnectorLink);
        }
    };

    latestIndexedRecordsTextArea = new LoggingTextArea("latestIndexedRecordsTextArea",
            new LoadableDetachableModel() {
                @Override
                protected Object load() {
                    RecordCollection collection = getRecordCollection();
                    return StatusManager.listLastIndexedRecords(collection);
                }
            }, refreshTimeMillis);

    connectorTraversalTextAreasListView = new ListView("connectorTraversalTextAreas", connectorsModel) {
        @Override
        protected void populateItem(ListItem item) {
            ConnectorInstance connectorInstance = (ConnectorInstance) item.getModelObject();
            final ReloadableEntityModel<ConnectorInstance> connectorInstanceModel = new ReloadableEntityModel<ConnectorInstance>(
                    connectorInstance);
            Label displayNameLabel = new Label("displayName", connectorInstance.getDisplayName());

            LoggingTextArea traversalTextArea = new LoggingTextArea("traversalTextArea",
                    new LoadableDetachableModel() {
                        @Override
                        protected Object load() {
                            ConnectorInstance connectorInstance = connectorInstanceModel.getObject();
                            return StatusManager.listLastTraversedRecords(connectorInstance);
                        }
                    }, refreshTimeMillis) {
                @Override
                public void detachModels() {
                    connectorInstanceModel.detach();
                    super.detachModels();
                }
            };

            item.add(displayNameLabel);
            item.add(traversalTextArea);
        }
    };
    // connectorTextAreasListView.setReuseItems(true);

    add(manageConnectorsLink);
    add(synchronizeIndexFieldsLink);
    add(manageIndexFieldsLink);
    add(recordCountLabel);
    add(deleteAllLink);
    add(indexedRecordCountLabel);
    add(controlIndexingButtons);
    controlIndexingButtons.add(reindexAllLink);
    controlIndexingButtons.add(resumeIndexingLink);
    controlIndexingButtons.add(optimizeLink);
    add(indexSizeOnDiskLabel);
    add(connectorTraversalStatesListView);
    add(latestIndexedRecordsTextArea);
    add(connectorTraversalTextAreasListView);

    /*
     * Quotas Part of the code :
     * antoine.timonnier@gmail.com
     */

    //Loading the size of the disk
    IModel model1 = new LoadableDetachableModel() {
        protected Object load() {
            return getsizeDisk();
        }
    };

    //Loading the number of documents indexed
    IModel model2 = new LoadableDetachableModel() {
        protected Object load() {
            return getindexedRecords();
        }
    };

    //Boolean that is true if both of the quotas are reached
    boolean bothQuotas = false;
    QuotasManagerImpl quotasManager = new QuotasManagerImpl();
    //TODO connect quotas manager with the quotas.properties
    /*double quotaSizeDisk = quotasManager.getQuotaSizeDisk();
    double quotaIndexedRecords = quotasManager.getQuotaIndexedRecords();
    double quotaPercentage = quotasManager.getQuotaPercentage();*/
    double quotaSizeDisk = 1;
    double quotaIndexedRecords = 1;
    double quotaPercentage = 70;
    double percentageSizeDisk = (sizeDisk * 100) / quotaSizeDisk;
    double percentageIndexedRecords = (indexedRecords * 100) / quotaIndexedRecords;

    //if the size of the disk is upper the quota percentage and doesn't reach the quota (lower than 100%)
    if (quotaPercentage < percentageSizeDisk && percentageSizeDisk < 100) {
        final String textPercentageSizeDisk = "Vous tes rendu  " + Double.toString(percentageSizeDisk)
                + "% de votre quota d'espace disque, veuillez contacter un administrateur !";
        configurePopUp(popUpPercentageSizeDisk, textPercentageSizeDisk, "Attention");
    }
    add(popUpPercentageSizeDisk);

    //if the number of doc indexed is upper the quota percentage and doesn't reach the quota (lower than 100%)
    if (quotaIndexedRecords < percentageIndexedRecords && percentageIndexedRecords < 100) {
        final String textPercentageIndexedRecords = "Vous tes rendu  " + Double.toString(percentageSizeDisk)
                + "% de votre quota de nombre de documents indexs, veuillez contacter un administrateur !";
        configurePopUp(popUpPercentageIndexedRecords, textPercentageIndexedRecords, "Attention");
    }
    add(popUpPercentageIndexedRecords);

    //Adding a pop up if both of the quotas are reached
    popUpBothQuotas = new ModalWindow("popUpBothQuotas");
    if (sizeDisk > quotaSizeDisk && indexedRecords > quotaIndexedRecords) {
        bothQuotas = true;
        // Sending the email
        // TODO sendEmail(String hostName, int smtpPort,
        // DefaultAuthenticator authenticator, String sender, String
        // subject, String message, String receiver);
        // TODO lock the indexing
        //Configuration of the popUp
        final String textBothQuotas = "Vous avez dpass votre quota d'espace disque et votre quotat de document indexs, veuillez contacter un administrateur";
        configurePopUp(popUpBothQuotas, textBothQuotas, "Attention");
    }
    add(popUpBothQuotas);

    //Adding a pop up if the size disk quota is reached
    popUpSizeDisk = new ModalWindow("popUpSizeDisk");
    boolean sizeDiskSuperior = sizeDisk > quotaSizeDisk;
    if (sizeDiskSuperior && bothQuotas == false) {
        /* Sending the email
        try {
           sendEmail("smtp.googlemail.com", 465, new DefaultAuthenticator("antoine.timonnier@gmail.com","quenellede300"), "antoine.timonnier@gmail.com", "constellio", "blabla", "antoine.timonnier@gmail.com");
        } catch (EmailException e) {
           // TODO Auto-generated catch block
           e.printStackTrace();
        } */
        // TODO lock
        // Configuration of the popup
        final String textSizeDisk = "Attention, vous avez dpass votre quota d'espace disque, veuillez contacter un administrateur";
        configurePopUp(popUpSizeDisk, textSizeDisk, "Attention");
    }
    add(popUpSizeDisk);

    //Adding a pop up if the indexed records quota is reached
    popUpIndexedRecords = new ModalWindow("popUpIndexedRecords");
    if (indexedRecords > quotaIndexedRecords && bothQuotas == false) {
        // sending the email
        // TODO sendEmail(String hostName, int smtpPort,
        // DefaultAuthenticator authenticator, String sender, String
        // subject, String message, String receiver);
        // TODO lock
        // Configuration of the popup
        final String textIndexedRecords = "Attention, vous avez dpass votre quota de documents indexs, veuillez contacter un administrateur. boolean both = "
                + bothQuotas;
        configurePopUp(popUpIndexedRecords, textIndexedRecords, "Attention");
    }
    add(popUpIndexedRecords);

}